VB.NET, Effective Crossing Window without EditorInput, DWGs Opened in Memor

VB.NET, Effective Crossing Window without EditorInput, DWGs Opened in Memor

Anonymous
Not applicable
1,195 Views
5 Replies
Message 1 of 6

VB.NET, Effective Crossing Window without EditorInput, DWGs Opened in Memor

Anonymous
Not applicable
I am building a VB.NET program to extract data from drawings without opening and rendering each drawing. I accomplish this with:

'Initialize Database Source as Read
Dim dbExtract As New DatabaseServices.Database
dbExtract.ReadDwgFile(FileName, IO.FileShare.Read, True, "")

Since this means that the drawings will be opened in memory, the EditorInput is not available which is where the crossing window selection set methods are. Does anyone know how to effectively search a designated window for any lines or plines that cross it without having the EditorInput?
0 Likes
1,196 Views
5 Replies
Replies (5)
Message 2 of 6

StephenPreston
Alumni
Alumni
The selection mechanism uses the display cache for speed. The normal way to do it 'in memory' is to iterate through the entities in model space querying their geometry against the area you want to select in. The simplest way to do this is to query their extents, but this can produce false hits for some geometries. A (relatively) simple alternative might be (for example) to create a region and call IntersectWith on that region passing in every entity you iterate through. That should base your geometric query on the actual entity graphics.

Your problem is that one way or another (without being able to use the display cache) you're iterating all the entities in model space.

Cheers,

Stephen
Autodesk Developer Network
Cheers,

Stephen Preston
Autodesk Developer Network
0 Likes
Message 3 of 6

Anonymous
Not applicable
It may also help if you knew that the EditorInput graphical selection
methods (window/crossing, fence, etc.) are only accurate to one display
pixel at the current view magnification (consider that if you zoom out far
enough, your entire drawing can fit within a single pixel).

Those methods are primarly for user-interactive selection, rather than
purely analytical selection or precise topograhical boundary classification.

Considering how often the request for this comes up in places like this, and
how often folks mistakenly assume that the EditorInput/(ssget) selection
methods are how it should be done, the lack of general APIs for doing
precise topographical operations like your case, is a long-standing and (if
you ask me) quite shameful belmish on AutoCAD programmability in general.

A well-designed high-level API should provide that functionality via a
formal protocol. Unfortunately, while the core functionality does exist in
AutoCAD, it is deeply buried in amonst other places, the BOUNDARY and HATCH
commands and the MPOLYGON custom object, and is not exposed via any API.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6200878@discussion.autodesk.com...
I am building a VB.NET program to extract data from drawings without opening
and rendering each drawing. I accomplish this with: 'Initialize Database
Source as Read Dim dbExtract As New DatabaseServices.Database
dbExtract.ReadDwgFile(FileName, IO.FileShare.Read, True, "") Since this
means that the drawings will be opened in memory, the EditorInput is not
available which is where the crossing window selection set methods are. Does
anyone know how to effectively search a designated window for any lines or
plines that cross it without having the EditorInput?
0 Likes
Message 4 of 6

Anonymous
Not applicable
You're right! Using the IntersectWith was the best approach. To assist others like myself who would like some reference information regarding the same issue I had, I've copied the important pieces of my code. Note though, I only cut and paste the pieces pertinent to this discussion.

The key to understanding this is that the IntersectWith method is using the Point3dCollection as a repository for the intersection points. Therefore, consider this argument as more of a ByRef and not ByVal when using IntersectWith.

'Create Point Collection for polygon crossing window and Assign Points
Dim ptcollSelectionWindowFront As New Point3dCollection
ptcollSelectionWindowFront.Add(ptTBPoint1)
ptcollSelectionWindowFront.Add(ptTBPoint2)
ptcollSelectionWindowFront.Add(ptExtTBPoint2)
ptcollSelectionWindowFront.Add(ptExtTBPoint1)

'Intialize Polygon Crossing Window
Dim polySelWindowFront As New DatabaseServices.Polyline2d(DatabaseServices.Poly2dType.SimplePoly, _
ptcollSelectionWindowFront, 0, True, 0, 0, Nothing)

'Initialize Crossing Indicator
Dim blnCrossing As Boolean = False

'Code here was to get the Entity as the program iterates through the entities
'Assigned each value in the iteration to 'CrossEntity'

'Determine if entity is Line/Pline and Crosses the window
If TypeOf CrossEntity Is DatabaseServices.Line Or TypeOf CrossEntity Is DatabaseServices.Polyline Then
Dim ptcollCross As New Point3dCollection
WindowPolygon.IntersectWith(CrossEntity, DatabaseServices.Intersect.OnBothOperands, ptcollCross, 0, 0)
If ptcollCross.Count > 0 Then
blnCrossing = True
Else
blnCrossing = False
End If
End If
0 Likes
Message 5 of 6

Anonymous
Not applicable
Try to dim a new Point3dcollection but all I'm getting is a "The specified module can not be found." error mesage.

Why would this happen?

(I'm trying to dim a collection to use with Intersectwith...)
0 Likes
Message 6 of 6

Anonymous
Not applicable
this works nice for the objects that are crossed by the rectangle, but how about those that are inside?
SelectCrossingWindows selects them both
0 Likes