VB .NET Select entities glitch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I am exporting entities properties to excel. A key command to get entities in a region.
It all works well at first, but then as the code loops through deferent regions (Move UCS), the selection return nothing at random times.
Here's my code to select all objects under a certain layer within a range, please help why would it glitch to works
Public Function GetObjectsLayer(objType As String, layerName As String) As SelectionSet
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim edt As Editor = doc.Editor
'Selection Criteria
'Additional typed value to include filter; now totaling = 2
Dim tv As TypedValue() = New TypedValue(2) {}
tv.SetValue(New TypedValue(CInt(DxfCode.Start), objType), 0) ' object type
tv.SetValue(New TypedValue(67, 0), 1) 'Select only from model space
tv.SetValue(New TypedValue(CInt(DxfCode.LayerName), layerName), 2) 'layer name
'Selection Range
' Define the corners of the selection window
Dim pt1 As Point3d = New Point3d(0, 4000, 0)
Dim pt2 As Point3d = New Point3d(5000, 0, 0)
'Convert points to WCS (world coordinate system)
Dim ucs As Matrix3d = edt.CurrentUserCoordinateSystem
' Transform points from UCS to WCS
Dim pt1Wcs As Point3d = pt1.TransformBy(ucs)
Dim pt2Wcs As Point3d = pt2.TransformBy(ucs)
Dim filter As SelectionFilter = New SelectionFilter(tv)
Dim psr As PromptSelectionResult = edt.SelectCrossingWindow(pt2, pt1, filter)
Dim ss As SelectionSet = psr.Value
Return ss
End Function