Jump to content

Problems getting 3d polyline coordinates


anibal_pp

Recommended Posts

I'm having problems just to understand how does the asignment and object creation occurs. In this case, I just wanna get the 3dpolyline's coordinates. Note that the polyline was already drawn by hand, I dont need to draw it from VBA, just read its properties

 

   Dim plineObj As Acad3DPolyline
   Dim fObject As AcadObject
   Dim ssetObj As AcadSelectionSet
   On Error Resume Next
   ThisDrawing.SelectionSets.Item("test_sel").Delete
   Set ssetObj = ThisDrawing.SelectionSets.Add("test_sel")
   ssetObj.SelectOnScreen


   For i = 0 To ssetObj.Count - 1
       Set fObject = ssetObj.Item(i)
       MsgBox fObject.ObjectName + "  " + fObject.Handle, vbYesNo,"test"
               
       If (fObject.ObjectName = "AcDb3dPolyline") Then
           ' ****problems with this assignment why??   (neither Set plineObj = fObject works)    
           Set plineObj = ssetObj.Item(i)
            
           ' Return all the coordinates of the polyline (doesnt work )
           Dim retCoord As Variant
           retCoord = plineObj.Coordinates
       
       End If
   Next i
   

regards,

anibal

Link to comment
Share on other sites

Your code runs fine here. Are you sure you are actually selecting a 3d polyline? Remember, there are *3* types of polylines ...

 

Also, you might just want to revisit the error handling - firstly, the "On Error Resume Next" call only works if you also have "Break on Unhandled Errors" selected in "Options". Some pc's seem to have "Break On All Errors" set.. in which case it will error out irregardless of your error trap.

 

Secondly, you never *cancelled* the error trap after your call for the selection set.. in which case, any error your code runs into (asuming you have "Break on Unhandled Errors" selected ) will not show you the error .. it will blindly go on with the next line of code.

 

At a minimum, I would double check the polyline type, and add an " On Error GoTo 0" after the line "ThisDrawing.SelectionSets.Item("test_sel").Delete"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...