Notifications
Clear all

[Closed] Z-Coordinate as spline name

Hi Guys,

I don´t know anything about max script but want to get it a little.
Right now I want to archive this:

I have hundrest of splies named after their want to be position in the Z-Axis.
For Exsample: spline named: 4 is supposed to be move to the Z-Coordinate 4
All splines are at 0 right now and I am going to model a massive Topographic Model.

Do you have any tip how to start or by any chance a script that will do it?

1 Reply

Here’s a simple one. Finds the first occurrence of an integer in a name of the form “spline_012_R”, “spline-09” or “level 9001 spline” (but not “Spline003”) and sets the z position of the object to the value. I’m sure you can figure out how to modify it to scale the values or add an offset to the z values.

undo on
(
	local filtArr 
	local found, execd
	local i
	for obj in selection do
	(
		filtArr = (filterstring obj.name "_ -")       -- divide the name into an array of parts, separators are either underscore, space or dash, add other separators to the second string if needed

		i = 1
		found = false
		while i <= filtArr.count AND found == false do
		(
			execd = (execute filtArr[i])		-- try to "run" the part of the name in order to get a value
			if classof execd == integer then found = true		-- check if the part executed as integer value; if yes - exit loop
			i += 1
		)
		if found then obj.position.z = execd
			else print (obj.name + ": the name does not include an integer value; ignored." )
	)
)