.NET

.NET

Reply
Valued Contributor
yaqiz
Posts: 86
Registered: ‎07-14-2010
Message 1 of 13 (391 Views)

How do I know whether the polyline overlap itself?

391 Views, 12 Replies
10-05-2011 07:41 AM

Hi Guys,

 

I have a polyline and need to check whether it overlap itself. What do I need to do in vb.net?

 

Thanks

 

Yaqi

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 2 of 13 (369 Views)

Re: How do I know whether the polyline overlap itself?

10-06-2011 11:02 AM in reply to: yaqiz

There are several IntersectWith methods available from various classes, but I can recall that some or all of those methods have the specific limitation of not discovering self-intersecting polylines.  So without spending a bunch of time checking the help for each one of them, I would suggest getting the individual line segments (and/or arc segments) and checking each one of those for intersections with each of the others.  I can probably work something up pretty quick, if you need it.

 

Dave O.                                                                  Sig-Logos32.png
Member
abdul.rafee
Posts: 3
Registered: ‎01-22-2013
Message 3 of 13 (287 Views)

Re: How do I know whether the polyline overlap itself?

02-25-2013 11:46 PM in reply to: yaqiz

Please help me to send that code to my mail id if possible.

 

my mail id id abdulrfaee.gis@gmail.com

 

Thank you.

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 4 of 13 (265 Views)

Re: How do I know whether the polyline overlap itself?

02-26-2013 11:18 PM in reply to: abdul.rafee

To provide code that actually works, we would need to know the version of AutoCAD you are working with, in particular wether you are working with 2010-2012/or 2013 or greater.  If you are working with older than 2010, that may make a difference as well.

 

Also, if you could provide the code you have, along with the specific problem you have, we could help you fix it.

 

Lastly, regardless of the previous suggestions, I would only post my code to this forum.  If I email it to you, then only you can benefit from it, but if I post it here then others can also find it.

 

it is clear that your first language is not English, so I hope you can understand or translate what I am saying properly.

Dave O.                                                                  Sig-Logos32.png
Active Contributor
DouceDeux
Posts: 47
Registered: ‎09-04-2012
Message 5 of 13 (259 Views)

Re: How do I know whether the polyline overlap itself?

02-27-2013 05:29 AM in reply to: yaqiz

I have an idea.

How about getting the start and end points for the line segments and using linear algebra to check if any of those lines intersect O.o? But if you have arcs in the polyline... then I wouldn't know what to do XD

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 6 of 13 (237 Views)

Re: How do I know whether the polyline overlap itself?

02-27-2013 10:28 PM in reply to: DouceDeux

DouceDeux wrote:

I have an idea.

How about getting the start and end points for the line segments and using linear algebra to check if any of those lines intersect O.o? But if you have arcs in the polyline... then I wouldn't know what to do XD


Or, he could just P/Invoke this:

 

    bool acdbIsRealSelfIntersectEntity(class AcDbEntity *)

Moderator
Alexander.Rivilis
Posts: 1,457
Registered: ‎04-09-2008
Message 7 of 13 (232 Views)

Re: How do I know whether the polyline overlap itself?

02-28-2013 04:22 AM in reply to: DiningPhilosopher

Tony! You dug another undocumented function? :smileyhappy:


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
DouceDeux
Posts: 47
Registered: ‎09-04-2012
Message 8 of 13 (226 Views)

Re: How do I know whether the polyline overlap itself?

02-28-2013 06:39 AM in reply to: Alexander.Rivilis

XD

Now that I think about it, you could create an approximate function for the curve (arc) and with a margin error, check if the polyline intersects itself.

I just wonder how the function tells the polyline intersects itself. I'm sure it would be much easier for that value to be calculated just once everytime the polyline changes and then just be accessed instead of it being calculated everytime a method be called. both scenarios have their prons and cons >.<

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 9 of 13 (214 Views)

Re: How do I know whether the polyline overlap itself?

02-28-2013 03:05 PM in reply to: DouceDeux

There is no need for that.  If you simply break the polyline down into its components, using GetSegmentType to tell you whether to call GetArcSegmentAt or GetLineSegmentAt, then you will have a collection of CircularArc3d, and LineSegment3d.  then you can loop through that collection calling IntersectWith on all the other objects in the collection, and make sure to ignore any intersections that may appear because of the coincident start and end points of adjacent segments.

 

You could probably even make it logically simpler, but programmatically messier, by calling explode on the polyline to get a collection of Lines and Arcs.

 

That said, the PInvoke mentioned above is intriguing, but I don't see the function documented in the 2012 Arx SDK, so I'll have to do some digging to see if I can find it, unless Tony would like to elaborate on the signature.

Dave O.                                                                  Sig-Logos32.png
Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 10 of 13 (189 Views)

Re: How do I know whether the polyline overlap itself?

02-28-2013 06:20 PM in reply to: chiefbraincloud

chiefbraincloud wrote:

 

That said, the PInvoke mentioned above is intriguing, but I don't see the function documented in the 2012 Arx SDK, so I'll have to do some digging to see if I can find it, unless Tony would like to elaborate on the signature.


The function isn't documented, meaning the standard caveat applies: Use it at your own risk.

 

Of course, one can't help but wonder why the public API of a $4K CADD product can't answer a simple question like the one asked by the subject line of this thread.

 

The entry point signature is platform-dependent, and you can find it acdbxx.dll, by using Depends.exe or dumpbin.

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.