Clones Merge

Hello there,

Is there anyone avaiable to make a script which:

If it finds that there are objects with the same name, it'll collapse them into single object

For example:

Box00<- I want these two to be only one Box00, The result would be a single: Box00
Box00<-
Box01<- I want these two to be only one Box01, The result would be a single: Box01
Box01<-

And so on... if it finds two Box02 it'll collapse the two and make only one Box02

Thanks for any help, and forgive me for my bad or better, "stupid" english ;)

Comments

Comment viewing options

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

Sure i'll do :) When i get

Sure i'll do :) When i get back home i'll give it a try.

real08121985's picture

Note that non poly/mesh

Note that non poly/mesh objects will be converted to poly! Maybe first test this script, before using it seriously.

(
	try destroyDialog rlCollapseByObjectName catch()
	global rlCollapseByObjectName = rollout rlCollapseByObjectName "Collapse by Objectname" (
		-- controls
			button butCollByObjName "Start"
		-- functions
			fn fnCollByObjName = (
				-- collect unique objectnames
					local aUniqObjNames = #()
					for Obj in selection do (
						local iArrInd = findItem aUniqObjNames Obj.name	
						if iArrInd == 0 do append aUniqObjNames Obj.name
					)
				-- attach double objectnames to the unique objectnames
					for sObjName in aUniqObjNames do (
						local aObjs = getNodeByName sObjName all:true
						if aObjs.count > 1 do (
							local FirstObj = aObjs[1]
							-- collapse non poly/mesh objects to poly
								if classof FirstObj != Editable_mesh or classof FirstObj != Editable_Poly do
									convertToPoly(FirstObj)
							-- attach double objects to first object
								for iObj=2 to aObjs.count do (
									local AttachObj = aObjs[iObj]
									case (classof FirstObj) of (
										Editable_mesh: meshop.attach FirstObj AttachObj
										Editable_Poly: polyop.attach FirstObj AttachObj
									)
								)
						)
					)
			)
		-- events
			on butCollByObjName pressed do fnCollByObjName()
	)
	createDialog rlCollapseByObjectName 160 30 style:#( #style_toolwindow, #style_sysmenu )
)

Comment viewing options

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