Jump to content

Pline by Excel VBA


b2b2
 Share

Recommended Posts

Hi all, i have small problem i am new in VBA and i am trying to write easy script in excel vba... i want to make a polyline from points i use this syntax, i cant find mistake but when i run macro it show me error 91 

 

Can someone help me, thanks a lot

Sub pline()

Dim plineObj As AcadLWPolyline
Dim Points(0 To 15) As Double
Dim AcadDwg As AcadDocument

'Define the polyline Coordinates XY, XY, XY .....
Points(0) = 0: Points(1) = 0
Points(2) = 1: Points(3) = 1
Points(4) = 5: Points(5) = 3
Points(6) = 4: Points(7) = 6
Points(8) = 8: Points(9) = 8
Points(10) = 20: Points(11) = 0
Points(12) = 25: Points(13) = 5
Points(14) = 100: Points(15) = 100

' Create a lightweight Polyline object in model space
Set plineObj = AcadDwg.ModelSpace.AddLightWeightPolyline(Points)

End Sub

Link to comment
Share on other sites

A google revealed a subtle difference, Works now.

 

Just a comment if your going to make a sub pline then it would be better to make the number of points non fixed and pass to the function X & Y & Z as required. Note requires a minimum of 2 points. I do most in lisp so sorry. 

 

Set plineObj = AcadDwg.ModelSpace.AddLightWeightPolyline(Points)
try
Set plineObj = Thisdrawing.ModelSpace.AddLightWeightPolyline(Points)

 

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
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.

 Share

×
×
  • Create New...