Clone objects and add a name extention

Hey guys.. looking for a script that will clone All selected objects, and add a name extension to the original object's names.
For example Box_01 and Box_02 cloned to Box_01_New-text-here and Box_02_New-text-here, than create a new layer and be able to name that for the group of selected objects that were cloned.

Comments

Comment viewing options

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

Perfect as always Miauu!!

Perfect as always Miauu!! thanks!

miauu's picture

.

Glad to help. :)

miauu's picture

.

(
	global rol_Clone
	try(destroyDialog rol_Clone)catch()
	rollout rol_Clone ""
	(
		edittext et_suffix "Suffix:" text:""
		edittext et_layerName "Layer Name:" text:""
		group "Offset:"
		(
			spinner spn_offsetX "X:" range:[-1e9,1e9,0] type:#worldunits
			spinner spn_offsetY "Y:" range:[-1e9,1e9,0]  type:#worldunits
			spinner spn_offsetZ "Z:" range:[-1e9,1e9,0]  type:#worldunits
		)
		button btn_clone "Clone"
 
		on btn_clone pressed do
		(
			local objToCloneArr = selection as array
			local newObjsArr = #()
			for o in objToCloneArr do
			(
				local newNodesArr = #()
				maxOps.CloneNodes o offset:[spn_offsetX.value,spn_offsetY.value,spn_offsetZ.value] expandHierarchy:false cloneType:#copy newNodes:&newNodesArr
				newNodesArr[1].name = o.name + et_suffix.text
				append newObjsArr newNodesArr[1]
			)
			if newObjsArr.count != 0 do
			(
				if et_layerName.text != "" then
				(
					if LayerManager.getLayerFromName et_layerName.text == undefined 	then
					(
						newLayer = LayerManager.newLayerFromName et_layerName.text
						for o in newObjsArr do newLayer.addNode o
					)
					else
					(
						newLayer = LayerManager.getLayerFromName et_layerName.text
						for o in newObjsArr do newLayer.addNode o
					)
				)
			)
		)		
	)
	createdialog rol_Clone 
)

Comment viewing options

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