Jump to content

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


bjhuffin

Recommended Posts

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

 

'Initialize Database Source as Read

Dim dbExtract AsNew 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?

Link to comment
Share on other sites

  • 3 weeks later...

Well, I figured it out... Below is a copy of segments from my code to assist others like myself that would like to know. The trick is in using the IntersectWith method of the polyline object. Also note that you have to initialize an empty Point3dCollection that the IntersectWith method will populate points into regarding the entity your attempting to verify. In other words, think ByRef and not ByVal for this argument:

 

'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

Link to comment
Share on other sites

Nice improvisation. :thumbsup:

 

A window crossing selection performed within the drawing editor would include entities inside the window even if their geometry did not cross the window’s border. The posted portion of your routine does not seem to include these items: Are those entities not a factor? Or, is there additional code not shown – GeometricExtents analysis perhaps?

Link to comment
Share on other sites

  • 3 weeks later...

Those entities are not a factor. This was to pick up plines and lines that are extended to represent cabling in a wiring diagram. So you're right, if they were small and within the crossing window, I would miss them. But fortunately in this situation, that would be a very rare situation to expect.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...