Hi ,
I have a problem while executing intersectwith between polylines and lines
the polyline execute intersectwith method referencing a line object with expandboth parameter value
but sometimes , the intersection is not found
when using expandthis or expandargument values, I have no problems
I'am using VS2012 express and Autocad 2014
the attached project containt :
an image (result;png) showing my result
a dwg file (dessin3.dwg) , it is my test file
the source code for testing , (test" command)
it find all polylines and all lines in the drawing , compute the intersections between each couple and draw a dbpoint on each
can you help me ?
thanks
Regards
Luc
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
start command _UNITS and set the number of decimal placed for "Length" ==> "Precision" to the maximum.
Then select the lowest red line and look to the Z-values for start- and endpoint.
Having different Z-values ends most of the time in problems. 😉
- alfred -
Luc,
Try this code instead
<CommandMethod("test3")> _ Public Shared Sub test3() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim Ed As Editor = doc.Editor Dim FilterList(0) As TypedValue FilterList.SetValue(New TypedValue(DxfCode.Start, "*POLYLINE"), 0) Dim Filtre As New SelectionFilter(FilterList) Dim Sel As PromptSelectionResult = Ed.SelectAll(Filtre) Dim IdsPoly() As ObjectId = Sel.Value.GetObjectIds Dim FilterList2(0) As TypedValue FilterList2.SetValue(New TypedValue(DxfCode.Start, "LINE"), 0) Dim Filtre2 As New SelectionFilter(FilterList2) Sel = Ed.SelectAll(Filtre2) Dim IdsLine() As ObjectId = Sel.Value.GetObjectIds Using TR As Transaction = db.TransactionManager.StartTransaction Dim ModelSpaceId As ObjectId = SymbolUtilityServices.GetBlockModelSpaceId(db) Dim btr As BlockTableRecord = TR.GetObject(ModelSpaceId, OpenMode.ForWrite) For P = LBound(IdsPoly) To UBound(IdsPoly) Dim Idpoly As ObjectId = IdsPoly(P) Dim Poly As Polyline = TR.GetObject(Idpoly, OpenMode.ForRead) For L = LBound(IdsLine) To UBound(IdsLine) Dim id As ObjectId = IdsLine(L) Dim pts As New Point3dCollection Dim Lig As Autodesk.AutoCAD.DatabaseServices.Line = CType(TR.GetObject(id, OpenMode.ForRead), Autodesk.AutoCAD.DatabaseServices.Line) 'assuming just extend lines to get intersection Lig.IntersectWith(Poly, Intersect.ExtendThis, pts, IntPtr.Zero, IntPtr.Zero) For Each Pt As Point3d In pts 'original code commented : 'Dim d As New DBPoint 'd.SetDatabaseDefaults() 'd.Position = Pt 'btr.AppendEntity(d) 'TR.AddNewlyCreatedDBObject(d, True) Dim c As Circle = New Circle(Pt, Vector3d.ZAxis, 15) c.ColorIndex = 1 btr.AppendEntity(c) TR.AddNewlyCreatedDBObject(c, True) Next Next Next TR.Commit() End Using End Sub
Can't find what you're looking for? Ask the community or share your knowledge.