Notifications
Clear all

[Closed] Select spline point by world position

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

4 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

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?

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?

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

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…

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.