title: AutoCAD VBA: Selecting objects
body: <p>I have a 3D model of an intricate chimney which is essentially a cylindrical tube with decorative features. I'd like to write a VBA script which find the section properties at several points along its length but I'm not really sure how to do it. </p>
  
  <p>From online searches, I've managed to write a code which puts in a section at a point which I can then run MASSPROP on but I'm not quite sure how to finish it off... I think I'm only one line of code away. I just need to select the section that I've just created.</p>
  
  <p>My almost complete code is below with a comment on the line that I need help with.</p>
  
  <pre><code>Public Sub Section()
  Dim SolidObject As Acad3DSolid
  Dim NewRegionObject As AcadRegion
  Dim PlaneOrigin As Variant
  Dim PlaneXaxisPoint As Variant
  Dim PlaneYaxisPoint As Variant
  Dim PickedPoint As Variant
  On Error Resume Next
  With ThisDrawing.Utility
  .GetEntity SolidObject, PickedPoint, vbCr &amp; "Select solid to cut."
  If Err Then
      MsgBox "Selected solid must be a 3DSolid"
      Exit Sub
  End If
  PlaneOrigin = .GetPoint(PickedPoint, vbCr &amp; "Select point to define origin.")
  PlaneXaxisPoint = .GetPoint(PickedPoint, vbCr &amp; "Select point to define x-axis.")
  PlaneYaxisPoint = .GetPoint(PickedPoint, vbCr &amp; "Select point to define y-axis.")
  Set NewRegionObject = SolidObject.SectionSolid(PlaneOrigin, PlaneXaxisPoint, PlaneYaxisPoint)
  End With
  ThisDrawing.SendCommand ("qaflags" &amp; vbCr &amp; "2" &amp; vbCr) 'This is needed for the operation
  ThisDrawing.SendCommand ("massprop" &amp; vbCr)
  'How do I select my NewRegionObject???
  ThisDrawing.SendCommand (vbCr &amp; vbCr &amp; "y" &amp; vbCr &amp; vbCr &amp; "y" &amp; vbCr)
  End Sub
  </code></pre>
  
  <p>If I can get this code to run MASSPROP with my newly created section fine I should be able to adapt it to do the process automatically at several points along the chimney so I think I'm only one line of code off.</p>
  
  <p>Thanks for your help,
  Tom</p>