Jump to content

IntersectWith not working


Jozi68

Recommended Posts

I work in 2D, and use vb.net

 

I have a closed Polyline (rectangle). I have a line going right through it, i.e. it intersects twice. I am using the following code:

 

Dim colIntersection AsNew Point3dCollection

myLine.IntersectWith(MyPolyLine, Intersect.OnBothOperands, _ colIntersection, 1, 1)

 

For some strange reason, the colIntersection.Count is always equal to 1. I.e, it only finds one of the intersection points.

Does anyone know how to get them both?

Link to comment
Share on other sites

I've tried this:

 

Dim colIntersection As Point3dCollection = New Point3dCollection(myLine.IntersectWith(MyPolyLine))

 

I saw this code on the forum (http://www.cadtutor.net/forum/showthread.php?t=39190). A solution by SEANT and they claim it works!

 

I, on the other hand get the following error: Error 1 Overload resolution failed because no accessible 'IntersectWith' accepts this number of arguments.

 

Using my code in the previous post, I've added quite a few lines that all intersect with this PolyLine twice. I always get one or NO intersection points returned, never 2, as I'm sure I should be getting.

Link to comment
Share on other sites

I saw this code on the forum (http://www.cadtutor.net/forum/showthread.php?t=39190). A solution by SEANT and they claim it works!

 

I, on the other hand get the following error: Error 1 Overload resolution failed because no accessible 'IntersectWith' accepts this number of arguments.

 

It sounds like there was an attempt to use this line of code:

 

Dim ptArray() As Point3d = ls.IntersectWith(ra3d)

 

with a standard database curve (without first converting it to the Autodesk.AutoCAD.Geometry counterpart).

 

I also notice your post at theswamp.org, where there appears to be solutions in responce to the question.

Link to comment
Share on other sites

  • 3 months later...

Hi Seant,

 

I'm trying to build a collection of points resulting from the intersection of a line with a polyline.

 

This code does not work...(AutoCAD keeps giving me the "Too Many Arguments" message and will not allow me to proceed until I remove the ", intersectPoints, 0, 0")...

Public intersectPoints As Autodesk.AutoCAD.Geometry.Point3dCollection

objACADEntity1.IntersectWith(objACADEntity2, Intersect.OnBothOperands, intersectPoints, 0, 0)

I'm not sure if this is working or not...but at least it does not error out...(this is the above code with the ", intersectPoints, 0, 0" removed)...

objACADEntity1.IntersectWith(objACADEntity2, Intersect.OnBothOperands)

I have a line assigned to the AutoCAD entity "objACADEntity1"

I have a polyline assigned to the AutoCAD entity "objACADEntity2"

 

Do I need to convert some ACAD entity into something else in order to build this collection?

 

What is the secret to finding the intersection points of a line and polyline??

 

Thanks Seant for your expert help!

 

It sounds like there was an attempt to use this line of code:

 

Dim ptArray() As Point3d = ls.IntersectWith(ra3d)

 

with a standard database curve (without first converting it to the Autodesk.AutoCAD.Geometry counterpart).

 

I also notice your post at theswamp.org, where there appears to be solutions in responce to the question.

Link to comment
Share on other sites

Hi Seant,

 

I'm trying to build a collection of points resulting from the intersection of a line with a polyline.

 

This code does not work...(AutoCAD keeps giving me the "Too Many Arguments" message and will not allow me to proceed until I remove the ", intersectPoints, 0, 0")...

 

Public intersectPoints As Autodesk.AutoCAD.Geometry.Point3dCollection

 

objACADEntity1.IntersectWith(objACADEntity2, Intersect.OnBothOperands, intersectPoints, 0, 0)

 

I'm not sure if this is working or not...but at least it does not error out...(this is the above code with the ", intersectPoints, 0, 0" removed)...

 

objACADEntity1.IntersectWith(objACADEntity2, Intersect.OnBothOperands)

 

I have a line assigned to the AutoCAD entity "objACADEntity1"

I have a polyline assigned to the AutoCAD entity "objACADEntity2"

 

Do I need to convert some ACAD entity into something else in order to build this collection?

 

What is the secret to finding the intersection points of a line and polyline??

 

Thanks Seant for your expert help!

 

Will be this working for you:

 

[size=3]<CommandMethod([/size][size=3][color=#a31515][size=3][color=#a31515]"inters"[/color][/size][/color][/size][size=3], CommandFlags.UsePickSet)> _[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Public [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Sub[/color][/size][/color][/size][size=3] GetInters()[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] doc [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Document = acadApp.DocumentManager.MdiActiveDocument[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] db [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Database = doc.Database[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] ed [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Editor = doc.Editor[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] tr [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Transaction = db.TransactionManager.StartTransaction[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Try[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Using[/color][/size][/color][/size][size=3] (tr)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] opt [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] PromptEntityOptions(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select line: "[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.SetRejectMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select line only"[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.AllowNone = [/size][size=3][color=#0000ff][size=3][color=#0000ff]False[/color][/size]
[/color][/size][size=3]opt.AllowObjectOnLockedLayer = [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size]
[/color][/size][size=3]opt.AddAllowedClass([/size][size=3][color=#0000ff][size=3][color=#0000ff]GetType[/color][/size][/color][/size][size=3](Line), [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size][/color][/size][size=3])[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] res [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] PromptEntityResult = ed.GetEntity(opt)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]If[/color][/size][/color][/size][size=3] res.Status <> PromptStatus.OK [/size][size=3][color=#0000ff][size=3][color=#0000ff]Then [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Return[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] lid [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] ObjectId = res.ObjectId[/size]
[size=3]opt.AddAllowedClass([/size][size=3][color=#0000ff][size=3][color=#0000ff]GetType[/color][/size][/color][/size][size=3](Polyline), [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.SetRejectMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select polyline only"[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.Message = vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select polyline: "[/color][/size]
[/color][/size][size=3]res = ed.GetEntity(opt)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]If[/color][/size][/color][/size][size=3] res.Status <> PromptStatus.OK [/size][size=3][color=#0000ff][size=3][color=#0000ff]Then [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Return[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] pid [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] ObjectId = res.ObjectId[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] pts [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Point3dCollection = [/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] Point3dCollection()[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"{0} <> {1};"[/color][/size][/color][/size][size=3], lid, pid)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] enl [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Line = [/size][size=3][color=#0000ff][size=3][color=#0000ff]CType[/color][/size][/color][/size][size=3](tr.GetObject(lid, OpenMode.ForRead), Line)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] enp [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Polyline = [/size][size=3][color=#0000ff][size=3][color=#0000ff]CType[/color][/size][/color][/size][size=3](tr.GetObject(pid, OpenMode.ForRead), Polyline)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] plane [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Plane = [/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] Plane(ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis)[/size]
[size=3]enl.IntersectWith(enp, Intersect.OnBothOperands, plane, pts, 0, 0)[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Number of intersections: {0}"[/color][/size][/color][/size][size=3], pts.Count)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] i [/size][size=3][color=#0000ff][size=3][color=#0000ff]As [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Integer[/color][/size][/color][/size][size=3] = 1[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]For [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Each[/color][/size][/color][/size][size=3] pt [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Point3d [/size][size=3][color=#0000ff][size=3][color=#0000ff]In[/color][/size][/color][/size][size=3] pts[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Point number {0}: ({1}, {2}, {3})"[/color][/size][/color][/size][size=3], i, pt.X, pt.Y, pt.Z)[/size]
[size=3]i += 1[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Next[/color][/size]
[/color][/size][size=3]tr.Commit()[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Using[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Catch[/color][/size][/color][/size][size=3] ex [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Autodesk.AutoCAD.Runtime.Exception[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"{0}"[/color][/size][/color][/size][size=3], ex.Message)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Try[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Sub[/color][/size]
[/color][/size]

 

~'J'~

Link to comment
Share on other sites

C'mon, friend

You make me laugh :)

Thank you

 

~'J'~

 

You’re welcome, fixo, and thank you.

 

And “thank you” to the rest of the contributors to this forum. May we all have the time and inclination to offer advice through this next decade.

Link to comment
Share on other sites

Thank you, but I can not get this code to work on my system.

 

If we start at the beginning, I think we might find the problem...

 

What would cause the following piece of code to generate a "The specified module could not be found." message?

 

Public intersectPoints As Autodesk.AutoCAD.Geometry.Point3dCollection

 

 

 

 

Will be this working for you:

 

[size=3]<CommandMethod([/size][size=3][color=#a31515][size=3][color=#a31515]"inters"[/color][/size][/color][/size][size=3], CommandFlags.UsePickSet)> _[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Public [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Sub[/color][/size][/color][/size][size=3] GetInters()[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] doc [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Document = acadApp.DocumentManager.MdiActiveDocument[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] db [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Database = doc.Database[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] ed [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Editor = doc.Editor[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] tr [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Transaction = db.TransactionManager.StartTransaction[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Try[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Using[/color][/size][/color][/size][size=3] (tr)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] opt [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] PromptEntityOptions(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select line: "[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.SetRejectMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select line only"[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.AllowNone = [/size][size=3][color=#0000ff][size=3][color=#0000ff]False[/color][/size]
[/color][/size][size=3]opt.AllowObjectOnLockedLayer = [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size]
[/color][/size][size=3]opt.AddAllowedClass([/size][size=3][color=#0000ff][size=3][color=#0000ff]GetType[/color][/size][/color][/size][size=3](Line), [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size][/color][/size][size=3])[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] res [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] PromptEntityResult = ed.GetEntity(opt)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]If[/color][/size][/color][/size][size=3] res.Status <> PromptStatus.OK [/size][size=3][color=#0000ff][size=3][color=#0000ff]Then [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Return[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] lid [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] ObjectId = res.ObjectId[/size]
[size=3]opt.AddAllowedClass([/size][size=3][color=#0000ff][size=3][color=#0000ff]GetType[/color][/size][/color][/size][size=3](Polyline), [/size][size=3][color=#0000ff][size=3][color=#0000ff]True[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.SetRejectMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select polyline only"[/color][/size][/color][/size][size=3])[/size]
[size=3]opt.Message = vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Select polyline: "[/color][/size]
[/color][/size][size=3]res = ed.GetEntity(opt)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]If[/color][/size][/color][/size][size=3] res.Status <> PromptStatus.OK [/size][size=3][color=#0000ff][size=3][color=#0000ff]Then [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Return[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] pid [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] ObjectId = res.ObjectId[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] pts [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Point3dCollection = [/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] Point3dCollection()[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"{0} <> {1};"[/color][/size][/color][/size][size=3], lid, pid)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] enl [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Line = [/size][size=3][color=#0000ff][size=3][color=#0000ff]CType[/color][/size][/color][/size][size=3](tr.GetObject(lid, OpenMode.ForRead), Line)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] enp [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Polyline = [/size][size=3][color=#0000ff][size=3][color=#0000ff]CType[/color][/size][/color][/size][size=3](tr.GetObject(pid, OpenMode.ForRead), Polyline)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] plane [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Plane = [/size][size=3][color=#0000ff][size=3][color=#0000ff]New[/color][/size][/color][/size][size=3] Plane(ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Origin, ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis)[/size]
[size=3]enl.IntersectWith(enp, Intersect.OnBothOperands, plane, pts, 0, 0)[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Number of intersections: {0}"[/color][/size][/color][/size][size=3], pts.Count)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Dim[/color][/size][/color][/size][size=3] i [/size][size=3][color=#0000ff][size=3][color=#0000ff]As [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Integer[/color][/size][/color][/size][size=3] = 1[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]For [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Each[/color][/size][/color][/size][size=3] pt [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Point3d [/size][size=3][color=#0000ff][size=3][color=#0000ff]In[/color][/size][/color][/size][size=3] pts[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"Point number {0}: ({1}, {2}, {3})"[/color][/size][/color][/size][size=3], i, pt.X, pt.Y, pt.Z)[/size]
[size=3]i += 1[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]Next[/color][/size]
[/color][/size][size=3]tr.Commit()[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Using[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Catch[/color][/size][/color][/size][size=3] ex [/size][size=3][color=#0000ff][size=3][color=#0000ff]As[/color][/size][/color][/size][size=3] Autodesk.AutoCAD.Runtime.Exception[/size]
[size=3]ed.WriteMessage(vbLf & [/size][size=3][color=#a31515][size=3][color=#a31515]"{0}"[/color][/size][/color][/size][size=3], ex.Message)[/size]
[size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Try[/color][/size]
[/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]End [/color][/size][/color][/size][size=3][color=#0000ff][size=3][color=#0000ff]Sub[/color][/size]
[/color][/size]

 

~'J'~

Link to comment
Share on other sites

Greetings SEANT,

 

Here are the imports for the form containing my Intersectwith code...

 

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Geometry

Imports System.Windows

Imports System.IO

I've got this working...

 

Dim colIntersection() AsDouble

colIntersection = objACADEntity1.IntersectWith(objACADEntity2, AcExtendOption.acExtendBoth)

MsgBox(colIntersection(0).ToString)

 

The ultimate goal of this exercise is to find the intersection points of a line and a polyline...then to change the endpoints of the line to these calculated intersection points...thus simulating an automatic line extend/trim function.

 

 

 

Thanks SEANT for your expertise!

 

 

Have you included this with the rest of the Imports?

 

Imports Autodesk.AutoCAD.Geometry

Link to comment
Share on other sites

Is the intention to run this as an out of process EXE?

 

If so, then it is essential to state that up front when asking AutoCAD related .NET question*. None of the Managed ARX libraries will be available, only the COM objects (similar to that available to VBA and VLisp) will be exposed through the Interop hook.

 

*This will prevent a lot of non-pertinent advice/examples from being directed your way.

 

If the intention is to run this as a DLL (loaded via NETLOAD) then ZIP and post the project here so we can see the whole setup.

Link to comment
Share on other sites

Good morning SEANT,

 

The intention is to run this as an out of process EXE...and it basically runs like a scalded cat. FAST.

 

So these are "Managed ARX" libraries? Ao:)nd as such, are unneeded in an out of process EXE?

 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

Imports Autodesk.AutoCAD.Geometry

I can remove these...great! I didn't like them anyway.

 

I discovered just a few minuters ago that my code works nicely...it just lumps all the point values into one array variable. See below...

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

Imports System.Windows

Imports System.IO

PublicSub bnTEST_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnTEST.Click

 

objAcad.ActiveDocument.Utility.GetEntity(objACADEntity1, pickpoint, "Select the line:")

objAcad.ActiveDocument.Utility.GetEntity(objACADEntity2, pickpoint, "Select the polyline:")

Dim colIntersection() AsDouble

colIntersection = objACADEntity1.IntersectWith(objACADEntity2, AcExtendOption.acExtendBoth)

MsgBox(colIntersection(0).ToString)

MsgBox(colIntersection(3).ToString)

End Sub

 

I think 0,1 and 2 are the values for the first intersection point and 3,4 and 5 and the values for the second intersection point.

 

I checked this on an arc and a polyline, and it works nicely too! (I think this whole routine will most likely be put into a Try-Catch-End Try in case the line or arc doesn't intersect with the polyline.)

 

Please accept my sincere apology for not knowing to tell you I am working on an out of process EXE. I'm learning!

 

Now for the next part of this exercise...how to redefine the line startpoint to the first intersection point, and the line endpoint to the second intersection point?

 

Something like...

 

objACADEntity1.StartPoint(colIntersection(0),colIntersection(1),colIntersection(2))

 

But of course that doesn't work...any suggestions?

 

 

Is the intention to run this as an out of process EXE?

 

If so, then it is essential to state that up front when asking AutoCAD related .NET question*. None of the Managed ARX libraries will be available, only the COM objects (similar to that available to VBA and VLisp) will be exposed through the Interop hook.

 

*This will prevent a lot of non-pertinent advice/examples from being directed your way.

 

If the intention is to run this as a DLL (loaded via NETLOAD) then ZIP and post the project here so we can see the whole setup.

Link to comment
Share on other sites

There are advantages to using ManagedARX when automating AutoCAD via .NET. There is a considerable increase in the amount of native AutoCAD functionality exposed. Some tasks, which are virtually impossible to do with COM/ActiveX, are now quite feasible.

The one drawback is that those native libraries are only exposed to in-process code.

 

There may be methods to mitigate that drawback; perhaps a deployment that leverages an executable for non AutoCAD specific tasks as well as a few key calls to a “netload”able DLL for all the heavy AutoCAD interaction. I should also point out that as fast as the out-of-process COM may now seem, it will likely cause a severe bottleneck as interaction increases.

 

I’ll probably be exploring that scenario in the months to come.

 

 

I think you should be able to do something like this (not tested):

 

Dim stpt() as Double = New Double(colIntersection(0), colIntersection(1), colIntersection(2))
Dim ndpt() as Double = New Double(colIntersection(3), colIntersection(4), colIntersection(5))

objACADEntity1.StartPoint = stpt
objACADEntity1.EndPoint = ndpt

Link to comment
Share on other sites

Thanks SEANT,

 

Got it working with lines and polylines now...I'm moving on to arcs.

 

"It do boggle the mind with the possibilities..."

 

Best regards and thanks for the guidance and expertise!

 

 

(CADTutor is quickly becoming my number 1 "go to" forum.)

 

 

 

I think you should be able to do something like this (not tested):

 

Dim stpt() as Double = New Double(colIntersection(0), colIntersection(1), colIntersection(2))
Dim ndpt() as Double = New Double(colIntersection(3), colIntersection(4), colIntersection(5))

objACADEntity1.StartPoint = stpt
objACADEntity1.EndPoint = ndpt

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...