Get Line Object Length

Get Line Object Length

Anonymous
Not applicable
863 Views
3 Replies
Message 1 of 4

Get Line Object Length

Anonymous
Not applicable
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

        Dim acCurDb As Database = acDoc.Database
        ed = acDoc.Editor

        Using acTrans = acCurDb.TransactionManager.StartTransaction()

            Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
            If acSSPrompt.Status = PromptStatus.OK Then

                acSSet = acSSPrompt.Value

                For Each acSSObj As SelectedObject In acSSet
                    If Not IsDBNull(acSSObj) Then
                        Dim acEnt As Entity = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite)

                        If Not IsDBNull(acEnt) Then

                            If TypeOf acEnt Is Line Then
                                Dim AcL As Line
                                AcL = acEnt

                                MsgBox(AcL.Area)
                               
                            End If
                        End If
                    End If
                Next
            End If
           
        End Using

 I need to get the line object length. i Have written the below code.


If i use area property i am getting zero.

 

Can anyone help me from this issue?

 

THank you.

0 Likes
Accepted solutions (1)
864 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Is this code correct? FP = AcL.StartPoint : SP = AcL.EndPoint Dim dx As Double = SP.X - FP.X Dim dy As Double = SP.Y - FP.Y Dim len As Double = Math.Sqrt((dx * dx) + (dy * dy))
0 Likes
Message 3 of 4

Alexander.Rivilis
Mentor
Mentor
Accepted solution
AcL.GetDistanceAtParameter(AcL.EndParam)

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 4 of 4

StephenPreston
Alumni
Alumni

If its just for a line, you can simply use the Length property. Or the Delta property if you want the length as a vector.

 

Cheers,

Stephen Preston
Autodesk Developer Network
0 Likes