Author Topic: Create an acadlwpolyline similar to pline command  (Read 4020 times)

0 Members and 1 Guest are viewing this topic.

poncelet

  • Guest
Create an acadlwpolyline similar to pline command
« on: September 22, 2011, 11:07:18 AM »
Hello,
I would like to create a sub that creates a lwpolyline similar to pline command.
That is:
I pick first point
I pick second point (a line segment is created)
I pick third point (a second line segment is created)
and so on...

I could create an object array to put all these line segments (acadline) and delete them at the end of the sub.
After that using the coordinates of the picked points create my lwpolyline.
But is there an easier way to have the same procedure?
Thanks

Ketxu

  • Newt
  • Posts: 109
Re: Create an acadlwpolyline similar to pline command
« Reply #1 on: September 22, 2011, 08:25:24 PM »
You should try Sendcommand to use built in Pline command ^^

poncelet

  • Guest
Re: Create an acadlwpolyline similar to pline command
« Reply #2 on: September 23, 2011, 06:03:19 AM »
Sendcommand should be the last option always

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Create an acadlwpolyline similar to pline command
« Reply #3 on: September 23, 2011, 08:58:06 AM »
Code: [Select]
Public Sub Main()
    Dim startPnt As Variant
    Dim returnPnt As Variant
    Dim returnPntList(0 To 5) As Double
    Dim plineObj As AcadPolyline

    startPnt = ThisDrawing.Utility.GetPoint(, "Pick starting point: ")
    ' Return a point using a prompt
    On Error Resume Next
   
    returnPnt = ThisDrawing.Utility.GetPoint(startPnt, "Pick the next point: ")
    If Err Then GoTo SubEnd
   
    returnPntList(0) = startPnt(0)
    returnPntList(1) = startPnt(1)
    returnPntList(2) = startPnt(2)
   
    returnPntList(3) = returnPnt(0)
    returnPntList(4) = returnPnt(1)
    returnPntList(5) = returnPnt(2)
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(returnPntList)
   
   
    While IsNull(returnPnt) = False
        returnPnt = ThisDrawing.Utility.GetPoint(returnPnt, "Pick the next point: ")
   
        If Err Then GoTo SubEnd
   
        plineObj.AppendVertex returnPnt
        ThisDrawing.Regen (acActiveViewport)
    Wend
   
SubEnd:
    ' Exit the command
End Sub
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

poncelet

  • Guest
Re: Create an acadlwpolyline similar to pline command
« Reply #4 on: September 23, 2011, 09:31:54 AM »
appendVertex
Thanks Matt
Much neater!

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Create an acadlwpolyline similar to pline command
« Reply #5 on: September 23, 2011, 09:33:25 AM »
You're welcome.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io