.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

intersectwith between polyline and lines problem

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
luc
Explorer
2255 Views, 3 Replies

intersectwith between polyline and lines problem

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

3 REPLIES 3
Message 2 of 4
Alfred.NESWADBA
in reply to: luc

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.

 

2013-11-25 11-10-14.png

Having different Z-values ends most of the time in problems. 😉

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 4
Hallex
in reply to: luc

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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 4
luc
Explorer
in reply to: Alfred.NESWADBA

Hi Alfred

You're right, the Z coordinate is the problem.

the mistake is why sometimes the intersection is found and sometime not

regards

Luc

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost