Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 2
nucliabrasil
886 Views, 1 Reply

Lenght

Hello!
How do I do to capture the new length an extended line and assign it to a variable?

Thanks!

Tags (2)
1 REPLY 1
Message 2 of 2

If you have the Line object, you can always get the Length property.

Sub Test()
  Dim pt1(2) As Double
  Dim pt2(2) As Double: pt2(0) = 10: pt2(1) = 10
  
  Dim myLine As AcadLine
  Set myLine = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
  
  Dim oldLen As Double
  oldLen = myLine.Length
  
  Dim newPt(2) As Double: newPt(0) = 20: newPt(1) = 20
  myLine.EndPoint = newPt
  
  Dim newLen As Double
  newLen = myLine.Length
  
  Debug.Print "Old length: " & oldLen & ", New length: " & newLen
End Sub
R. Robert Bell
BIM Manager
Stantec

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report