Clothoid 2 point curve script

 From:  Michael Gibson
5878.5 In reply to 5878.4 
Hi Brian,

> The two selection points need to be on a 2d plane.

So there are a few different possible ways you can do this, but each way will involve setting up pointpicker restrictions.

It's possible to make the points go on one completely predefined plane like only on the world x/y plane. But then someone has to be able to get at that plane in the view they are working with, like if they had a maximized Front view they couldn't get stuff created there because they plane they need to pick on is exactly edge-on to that view. Basically their picks would have no effect until they switched to a view that was not viewing that plane exactly at 90 degrees to it. So it's kind of nice to have the plane pick up something about what is being picked rather than totally hard coded.

Then the possible ways it can be controlled by picks is to either take the plane from the first point pick and then restrict the second point pick to that particular plane, or to do like the circle command does (and like I described above), where the first pick just sets up a "through point" and then the second pick defines the plane from the view the second point is picked in, and the plane taken is one that is parallel to the second pick's view but going through the first pick point. That allows for some flexibility with setting the depth of the plane with the first pick basically.


> The plane needs to be addressable in x and y coordinates, in order to plot the curve created with points
> derived by mathematics with x and y values, which I guess is what the var cplane = pointpicker.ptframe; does.

Once you do: var cplane = pointpicker.ptframe; cplane will contain a coordinate frame object that has it's origin at the picked point and has the x/y axis directions coming from the grid plane of the viewport that it was picked in. You can then use that coordinate frame to plot 2D points by doing: var pt = cplane.evaluate( x, y, 0.0 );


> I do not know why it did not work with the Right view.

Now I'm a little confused, you wrote above that it did work ok if both picks are in the Right view? With both picks in different views probably you are getting 2 points not on the same plane and causing problems from that.


> Or maybe I can set a frame on the 2d plane?

Basically a frame _is_ a 2d plane - it's an origin point with x/y/z axis directions, the origin and x/y axis directions form a plane, and if for example you want to create a point in world coordinates that has local coordinates at x = 5, y = 2 in that frame, you call frame.evaluate( 5, 2, 0 ); (the 0 is for the z value to use for elevation above or below the plane origin).

- Michael