Message 1 of 3

Not applicable
11-05-2014
01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am just starting to learn VB.NET and I am trying to get the length of polyline segments.
I ask the user to select the polylines and I explode them using entity.explode. This function provides the exploded segments as a dbobjectcollection. Nevertheless, when I try to open the dbobjects inside the collection I get an "exception error".
This is my code, I am getting the error in the bold line:
Public Class ARCommands
<CommandMethod("getlineslength")> _
Public Sub getlineslength()
Dim myDWG As Document = _
Application.DocumentManager.MdiActiveDocument
Dim myEd As Editor = myDWG.Editor
Dim acTypValAr(0) As TypedValue
acTypValAr.SetValue(New _
TypedValue(DxfCode.Start, _
"LWPOLYLINE"), 0)
Dim acSelFtr As SelectionFilter = _
New SelectionFilter(acTypValAr)
Dim myPSR As PromptSelectionResult = _
myEd.GetSelection(acSelFtr)
Dim myobjects As DBObjectCollection = _
New DBObjectCollection()
If myPSR.Status = PromptStatus.OK Then
Using myTrans As Transaction = _
myDWG.Database.TransactionManager.StartTransaction()
For Each so As SelectedObject In myPSR.Value
Dim myEnt As Entity = _
so.ObjectId.GetObject(OpenMode.ForRead)
myEnt.Explode(myobjects)
Next
For I As Integer = 1 To myobjects.Count - 1
Dim myobject As DBObject = _
myTrans.GetObject(myobjects.Item(I - 1). _
ObjectId, OpenMode.ForRead)
Dim myline As Line = _
myTrans.GetObject(myobject.ObjectId, _
OpenMode.ForRead)
MsgBox(myline.Length.ToString)
Next
myTrans.Commit()
End Using
End If
End Sub
End Class
Thank you,
Daniel Archila
Solved! Go to Solution.