Moving objects up the Z axis based on object name.

Hi,

I have a bunch of "floor plans" I'm batch-importing into Max. They all come in flat on the ground plane as single meshes. They are named "Floor_1, Floor_2, Floor_3" etc...

My task is to spatially separate these floor meshes, relative to each other, in order of their names. So I need to put the same amount of distance between each floor to form a multi-storied building up the Z axis. (Ex: Floor 1 stays on the ground. Floor 2 is four meters above Floor 1. Floor 3 is four meters above Floor 2...) No need for instances/copies here, just need to translate the existing geometry to its new location. Attached is a conceptual example of a final result.

I've been doing this by hand, but it's getting quite tedious, especially for stacks of a couple hundred. I've searched for an existing script to do this, but haven't been successful.

Many thanks for any guidance here.

~K

P.S. The ability to do the same thing with groups in addition to single objects would be really cool, but I'm setting sights on something simple for now.

AttachmentSize
floorstack.jpg291.62 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Stenrik's picture

Many thanks, Miauu!

This works and saves me a ton of time! I really appreciate the speedy reply with this. :)

I will experiment with making variations on it (such as moving/rotating along different axis) in short order.

miauu's picture

.

Single obejcts:

(
	--	"add as many names as you want"
	floorsNames = #("Floor_1", "Floor_2", "Floor_3", "Floor_4", "Floor_5")
 
	zDist = units.decodeValue "4m"
 
	--	" with objects"
	for i = 1 to floorsNames.count do
	(
		for o in objects where o.name == floorsNames[i] do
		(
			o.pos.z += zDist * (i - 1)
		)
	)
)

Groups:

(
	--	"add as many names as you want"
	floorsNames = #("Floor_1", "Floor_2", "Floor_3", "Floor_4", "Floor_5")
 
	zDist = units.decodeValue "4m"
 
	--	"get all groups"
	grpArr = for o in helpers where isGroupHead o collect o
	--	"with groups"
	for i = 1 to floorsNames.count do
	(
		for o in grpArr where o.name == floorsNames[i] do
		(
			o.pos.z += zDist * (i - 1)
		)
	)
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.