ScriptSpot

Forum topic · General Scripting

Duplicate Objets return value

By shorty1111 · 2017-09-16

Description

Hi im new in maxscript and i want to make script to find duplicate objects in the scene on button pressed. But, when i press button i want to my script just write how many of them found. then, on button "Clean" to clean duplicate objects :D sry for my english.

So, i dont want to get objet selected when script find objects...just to write how many

Ill post code i found on the internet. When i press button that script find and select objects.


		fn doubleSelect mode: del:off =
	(
		local objArr = objects as array
		local uniqueObjs = dataPair node:#() hash:#()
		for o in objArr where (findItem uniqueObjs.hash (e = gethashvalue o.pos 0)) == 0 do (append uniqueObjs.hash e ; append uniqueObjs.node o)

		select uniqueObjs.node ; max select invert
					
					if uniqueObjs.node != 0 do 
								(
									deleteObj.enabled = true
									cpObj.color = red
								)
		
		lbldObj.text="--  "+(selection.count as String+" deleted Objects!")
	)

Comments (1)

fajar · 2017-09-23

what do you mean by duplicate ? what kind of duplicate method it used , instance ,copy , or reference ? if its duplicate via copy then its hard to differentiate from another objects especially if you haven't tag it before (by adding custom attribute, etc ) before you copy it...but if its reference or instance it could be managed easily.