Jump to content
Developer Wiki and Function Reference Links ×

VS:ClosestPoints


AlanW

Recommended Posts

Hi Alan, below is a node layout that shows how you would write it in marionette.

Marionette is basically a sort of wrapper for python, so most of the calls/syntax must adhere to python rules.

Very briefly (Disclaimer: I am no Python expert, nor a Marionette one)

1. From the Dev Wiki : http://developer.vectorworks.net/index.php/VS:ClosestPoints

 vs.ClosestPoints(h1, h2):
     (pt1, pt2, touching)

- th inputs are h1 and h2, object handles. So that means this function must receive handles to two separate vectorworks objects.

-the 'return' displaying there is what this function outputs

--> pt1 and pt2 are Pts that have xy components, where in python terms would be of type 'tuple' ie (x, y); touching is of type 'boolean'  a true or false type variable.

2. Converting these into Marionette, you'd have to cater for these inputs and outputs.

ClosestPtsHelping.jpg

ClosestPtsHelping2.jpg

There are many ways to achieve this node, this is one of them.

Edited by twk
  • Like 1
Link to comment

Thanks for this, I get most of the simple stuff and have written a few simple nodes but final end what can be combined etc is really looking at other nodes and trial and error. I need to learn the real logic to it. I guess I will have to continue with learning Python, which is fun but I think I need to be under pressure with a course to really learn it.
Thanks again.

Created the node, most I had correct but it was the ending I was getting stuck on. See attached. I have drawn a line between the 2 points but they are not the closest points and also when you move the objects to intersect  the output is still false. Over to you, thanks

Closest points.JPG

Closest dist btw 2 objects.vwx

Edited by Alan Woodwell
add file
Link to comment

Alan,

I think its because VW sees the "points" on a circle (and possibly a polyline) as the curve handles. I converted your circles to NURBS curves (I had to rename them as the names disappeared in the conversion) but now it finds the closest points as expected.

Interestingly, if you use the Analysis tool which will also find the closest points between NURBS curves, the points by this script have a small margin of error. The loci in the second image are the points found by the Analysis tool....

Kevin

Screen Shot 2016-09-10 at 8.54.49 AM.pngScreen Shot 2016-09-10 at 8.58.47 AM.png

  • Like 1
Link to comment

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