PropertySet Formula Script to get vertice data from2d and 3d Polylines to provide as built information

PropertySet Formula Script to get vertice data from2d and 3d Polylines to provide as built information

ralstogj
Collaborator Collaborator
600 Views
1 Reply
Message 1 of 2

PropertySet Formula Script to get vertice data from2d and 3d Polylines to provide as built information

ralstogj
Collaborator
Collaborator

Hi

 

I am trying to build a property set to attached to 3d polyline as built information using a formula using a script that will return the start and end point elevations, but to start with I am trying to just return the length. Below is what i have come up with to date. When I change activedrawing to thisdrawing in VBA to test it works but having no luck as a script just returns the whole script as text.

 

Does any have examples of doing this that they could share or know what could be wrong.

 

 

 

RESULT = "--"
On Error Resume Next

Set oApp = GetObject(, "AutoCAD.Application")

' Runs in AutoCAD 2021 with axdb24enu.tlb (must be referenced) AutoCAD/ObjectDBX Common 24.0 Type Library


Set oAutocadApp = oApp.GetInterfaceObject("ObjectDBX.AxDbDocument.24")

Set obj = oAutocadApp.ActiveDocument.HandleToObject([Handle])

RESULT = obj.Length

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes
Accepted solutions (1)
601 Views
1 Reply
Reply (1)
Message 2 of 2

ralstogj
Collaborator
Collaborator
Accepted solution

Hi 

 

Got pointed in the right direction by this post

https://www.theswamp.org/index.php?topic=51871.0

 

Following code works for C#D 2021

 

Start Point

 

RESULT="--"
On Error Resume Next
Set app=GetObject(, "AutoCAD.Application.24")
Set aec = app.GetInterfaceObject("AecX.AecBaseApplication.8.3")
aec.Init app
Set obj=app.ActiveDocument.ObjectIdToObject([ObjectID])
pt = aec.ActiveDocument.Utility.ConvertToVariantArray(obj.Coordinates)
RESULT = "X= " & pt(0) & " Y=" & pt(1) & " Z=" & pt(2)

 

End Point

RESULT="--"
On Error Resume Next
Set app=GetObject(, "AutoCAD.Application.24")
Set aec = app.GetInterfaceObject("AecX.AecBaseApplication.8.3")
aec.Init app
Set obj=app.ActiveDocument.ObjectIdToObject([ObjectID])
pt = aec.ActiveDocument.Utility.ConvertToVariantArray(obj.Coordinates)
ptend = Ubound(pt,1)
RESULT = "X= " & pt(ptend-2) & " Y=" & pt(ptend-1) & " Z=" & pt(ptend)

 

Regards

 

Justin

 

 

 

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/