PDA

View Full Version : Select spline point by world position

 BobbyB11-25-2007, 06:32 AMHi gang I'm trying to figure out a scripting method to select all the the spline points that are in world space -x, which i would then be able to delete. If anyone could put me on the right path it would be much appreciated
Bobo
11-25-2007, 03:31 PM
Hi gang

I'm trying to figure out a scripting method to select all the the spline points that are in world space -x, which i would then be able to delete.

If anyone could put me on the right path it would be much appreciated

What have you tried and where did your method fail? :)

If you would loop through all splines in a shape, loop through their knots and compare each to the position you know (with an optional threashold, if you want), you should be able to select or delete them. Or am I missing something?

BobbyB
11-26-2007, 03:48 AM
On an object i would get the x position by doing something like

pos= \$pos.x

and then if do something to delete if it was not in the grid area i wanted like,

if pos>x then delete\$

How do it get the x position information of a spline knot?

Bobo
11-26-2007, 04:15 AM
On an object i would get the x position by doing something like

pos= \$pos.x

and then if do something to delete if it was not in the grid area i wanted like,

if pos>x then delete\$

How do it get the x position information of a spline knot?

Has to be Editable Spline (SplineShape class in MAXScript) to be able to delete directly.
You can use convertTo theShape SplineShape

fn delKnotsXGreaterThan theShape theVal =
(
convertTo theShape SplineShape --collapse to Editable Spline
for s = 1 to NumSplines theShape do --loop through all splines in the shape
for k = NumKnots theShape s to 1 by -1 where \ --count backwards
(getKnotPoint theShape s k).x > theVal do --if X is greater,
deleteKnot theShape s k --delete the knot
updateShape theShape --update the shape when done
)

delKnotsXGreaterThan \$ 10.0

For example, create a Donut shape with center at the Origin. Leave it selected and run the script - the vertices to the right of the origin and X > 10 will be deleted...

BobbyB
11-26-2007, 05:04 AM
Thanks that will give me something to work with.

What I am attempting to do is mirror spline guides I'm using for hair.
Usually i would copy half mirror it and and attach it to the original spline object. I just wanted to create a script that would do that for me.

But now i realise i will also have to script a way to mirror the splines without using the mirror tool, so that the world space is correct, and i can delete half when i want to mirror the spines again.

CGTalk Moderation
11-26-2007, 05:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.