Send

Speed ID

NOTICE

« Speed ​​ID » is a script designed to otpimize the process of assignement and management of Objects ids. it allows a faster and intuitive assignement for « Objects id » (even on geometry with their properties set to « not renderable » or « not visible » etc …). Also it making RenderElements Multimatte generating process very easy and fast. « Speed ​​ID » also allows to transfer and Reapply Object ID cross two scene with similar objects names. If you find any bug or for any suggestion or just to say thank-you : feel free to contact me or leave a comment.

If you like my script, or if you use them professionally. you can be nice and grateful, by making a donation. thank you!

- Set ID: assigns to Selected Objects the ID defined in the spinner .
- Select by ID : Select in viewport the object with ID defined in the spinner.
- Assigned ID: View ID currently assigned in the scene.
- List Update : updates the list of ID currently assigned in the scene.
- Reset sel ID: Resets to 0 all the Objects corresponding to the selected id in « assigned ID »
- Save All ID: Savegarde IDs of every objects present in the scene .
- Save Sel Obj ID: Savegarde IDs of any Selected object in the scene.
- Load All ID: reapplie previously Saved ID.( The names of the objects must be the same . The process can take several Minutes depending on the number of objects. 3dsmax can freezer during this time , so be Patient … )
- MultiMatte Suffix : Determine the name of Multimatte rendersElements .
- Generate MultiMatte : Generates Multimatte RenderElements according Object ID assigned in the scene.

This script is a macroscript.
Drag and drop it in your viewport and find it in customize>Custumize User interface. Category: « RomHua » > « Speed ID ».

CODE

--Script by romain Hua ROMHUA@GMAIL.COM
--www.romhua.com
try destroyDialog tempID catch()
rollout tempID "SpeedId" width:153 height:405
(
	spinner spn1 "" pos:[2,5] width:150 height:20 type:#integer range:[0,10000,0]
	button btnSetID "Set ID" pos:[2,23] width:74 height:25
	button btnSelectID "Select by ID" pos:[77,23] width:74 height:25
	hyperLink hlink "www.romhua.com" pos:[30,388] color:orange hoverColor:orange visitedColor:orange address:"www.romhua.com"
	edittext textid "Current selection Id:" pos:[2,50] width:149 height:18 labelOnTop:true text:"No selection..."
	listBox lbxAllID "Assigned id:" pos:[2,90] width:149 height:10
	button btnUlist "Update List" pos:[2,245] width:74 height:25
	button btnCid "Reset sel Id" pos:[77,245] width:74 height:25
	button SaveID "Save All ID" pos:[2,275] width:74 height:20
	button SaveSelObjID "S Sel Obj ID" pos:[2,295] width:74 height:20
	button LoadID "Load All ID" pos:[77,275] width:74 height:40
	edittext textMsuf "MultiMatte Suffix:" pos:[2,315] width:149 height:18 labelOnTop:true text:"MultiMatte"
	button btnGenMM "Generate MultiMatte" pos:[2,354] width:149 height:25
	progressBar pBar value:100 color:green width:150 height:10 pos:[1,380]

	/****************** FUNCTIONS****************/
	fn printObjId  id =
	(
		if id.count != 0 then (
		textid.text = id as string
		)
	)
	fn printNoSelect =
	(
		lbl1.text = "Select an object...."
	)
	fn compareFn el1 el2 =
	(
		return (el1 as integer) - (el2 as integer)
	)
	fn getAllid =
	(
		AllIDArr = #()
	for OBJ in Geometry do
		(
			id = OBJ.gbufferchannel as string
				if id != "0" then
				(
			appendIfUnique AllIDArr id
									)
		)
		qsort AllIDArr compareFN
		lbxAllID.items = AllIDArr

	)
	/****************** EVENTS HANDLER****************/
	on tempID open do
	(
		--lbl1.text = "Select an object...."
		callbacks.addScript #selectionSetChanged "sel = selection as array; IdArray = #(); for i = 1 to sel.count do (x = sel[i].gbufferchannel; append IdArray x); sort IdArray; tempID.printObjId IdArray" id:#myCallbackID
		getAllid()
	)
	on tempID close do
	(
		callbacks.removeScripts #selectionSetChanged id:#myCallbackID
	)
	on btnUlist pressed do
	(
		getAllid()
	)

	on SaveID pressed do
	(
		Allid = lbxAllID.items
		ArrayNodetoTxt = #()
		ArrayIDtoTxt = #()

		for i = 1 to Allid.count do
		(
		id = Allid[i]
		a1= (for o in geometry where o.gbufferchannel ==  id as integer collect o)
			for i = 1 to a1.count do
			(
				append ArrayIDtoTxt id as string
			)
		join ArrayNodetoTxt a1
		pBar.value = 100.*i/Allid.count

		)
		print ArrayIDtoTxt
		nodeTXT = createFile "$scripts\\nodes.txt"
		idTXT = createFile "$scripts\\nodesId.txt"
		for i = 1 to ArrayNodetoTxt.count do
		(

		format (ArrayNodetoTxt[i].name+"\n") to:nodeTXT
		format (ArrayIDtoTxt[i] as string+"\n") to:idTXT
		pBar.value = 100.*i/ArrayNodetoTxt.count
		)
	)
	on SaveSelObjID pressed do
	(
		Allid = lbxAllID.items
		ArrayNodetoTxt = #()
		ArrayIDtoTxt = #()

		for i = 1 to Allid.count do
		(
		id = Allid[i]
		a1= (for o in selection where o.gbufferchannel ==  id as integer collect o)
			for i = 1 to a1.count do
			(
				append ArrayIDtoTxt id as string
			)
		join ArrayNodetoTxt a1
		pBar.value = 100.*i/Allid.count

		)
		print ArrayIDtoTxt
		nodeTXT = createFile "$scripts\\nodes.txt"
		idTXT = createFile "$scripts\\nodesId.txt"
		for i = 1 to ArrayNodetoTxt.count do
		(

		format (ArrayNodetoTxt[i].name+"\n") to:nodeTXT
		format (ArrayIDtoTxt[i] as string+"\n") to:idTXT
		pBar.value = 100.*i/ArrayNodetoTxt.count
		)
	)
	on LoadID pressed do
	(
		messagebox "If the number of elements is large, the action can be very slow." title:"Notice:" beep:false
		NodeA = #()
		IdA = #()

		NodefileS  = openFile "$scripts\\nodes.txt" mode:"r"
		IDfileS = openFile "$scripts\\nodesId.txt" mode:"r"

		free NodeA
		free IdA
		free NewNodeArray

		NewNodeArray = #()

		while not eof NodefileS do
		(
			lineInfo = readLine NodefileS
			append NodeA lineInfo
		)
		print IdA
		close NodefileS

		while not eof IDfileS do
		(
			lineInfo = readLine IDfileS
			append IdA lineInfo
		)

		close IDfileS
		z = 1

		for i = 1 to NodeA.count do
		(
			pBar.value = 100.*i/NodeA.count
			targerNode = (for o in geometry where o.name == NodeA[i] as string collect o)
			if targerNode[1] != undefined then
			(
				targerNode[1].gbufferchannel = IdA[z] as integer
				z+=1
			)
			else
			(
				z+=1
			)
			free targerNode
		)
		free NodeA
		free IdA
		free NewNodeArray
	)
	on btnCid pressed do
	(
		Allid = lbxAllID.items
		if Allid.count != 0 then
	(
		z = lbxAllID.selection
		id = Allid[z]
		for o in geometry where o.gbufferchannel ==  id as integer do o.gbufferchannel = 0
		print ("reseted id :" +id)
		getAllid()
	)
	)
	on btnSetID pressed do
	(
		x = selection as array
			for i = 1 to x.count do
			(
				x[i].gbufferchannel = spn1.value
			)
	)
	on btnSelectID pressed do
	(
	selectedA = #()
	for OBJ in Geometry do
		(
			if OBJ.gbufferchannel == spn1.value then
			(
			append selectedA  OBJ
			)
		)
	select selectedA

	)
	on btnGenMM pressed do
	(
		getAllid()
		x = lbxAllID.items
		z = 1
		for i = 1 to x.count by 3 do
		(
			pBar.value = 100.*z/(x.count/3)
			r = maxOps.GetCurRenderElementMgr()
			m = MultiMatteElement()
			if x[i] != undefined then (m.R_gbufID = x[i] as integer; m.R_gbufIDOn = true) else (m.R_gbufID = 0; m.R_gbufIDOn = false)
			if x[i+1] != undefined then (m.G_gbufID = x[i+1] as integer; m.G_gbufIDOn = true) else (m.G_gbufID = 0; m.G_gbufIDOn = false)
			if x[i+2] != undefined then (m.B_gbufID = x[i+2] as integer; m.B_gbufIDOn = true) else (m.B_gbufID = 0; m.B_gbufIDOn = false)
			m.elementname = (textMsuf.text+"_"+z as string)
			r.AddRenderElement m
			z+=1
		)
	)
	on lbxAllID doubleClicked z do
	(
		Allid = lbxAllID.items
		id = Allid[z]
		print ("select id :" +id)
		select(for o in geometry where o.gbufferchannel ==  id as integer collect o)
	)
)
createDialog tempID
01

Leave a Reply

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *