bjhuffin Posted June 12, 2009 Posted June 12, 2009 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? Quote
bjhuffin Posted June 29, 2009 Author Posted June 29, 2009 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 Quote
SEANT Posted June 29, 2009 Posted June 29, 2009 Nice improvisation. 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? Quote
bjhuffin Posted July 16, 2009 Author Posted July 16, 2009 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. Quote
Recommended Posts
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.