Jump to content
caravanio

VectorScript: Detect self-intersecting polygon/polylines

Recommended Posts

Hello, all. Looking at the VectorScript function reference I see no functions that could tell whether a given polygon/polyline is self-intersecting. The only function that is told that it 

Quote

"... Should remove self-intersecting segments from the result. ..."

is the VS:OffsetPoly. But I don't want to see if a polygon/polyline is self intersecting as a side effect of an operation that actively acts on the selected object but just a read-only operation whether it is self-intersecting or not. Any suggestions are welcome.

Share this post


Link to post

I just played around with the script some more and realized that it only catches certain cases. The script basically creates two identical copies of the source poly and does an "intersect surface" on them. It will detect polys that intersect themselves like the poly to the right (in the attached image) because the "intersect surface" function will result in separate polys on each side of the intersection. So it does intersect surface, then counts to resultant polys. If there are more than one, the poly intersects. However, the poly on the left (in the image) will not be detected. I have some ideas of how this might be done but I need to spend a little more time.

 

Screen Shot 2017-01-20 at 9.53.01 AM.png

Share this post


Link to post

Yes, the long way is not as fun. ;-)

Try the revised script (attached).  I think this may do it for you.  I also added comments to explain what it's doing.

Let me know how it works for you if you use it.

DoesPolySelfIntersectFunc.vs

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×