macroScript FindObjects
	category:"!animation tools"
	toolTip:"Tool for searching missed objects"
	icon:#("TrackViewTools",43)
(
global ver;
global obfield;
global q=#();
global a = "";
global txt;
rollout findObj "Find object"
(
	edittext findname "Type a search name:"
	button findok "Find!" across:3;  offset:[80,0]
	button selok "Select!"   offset:[40,0]
	checkbutton unhideok "Unhide!"  offset:[10,0] width:60
	edittext obtype "Object class:" text:"Geometry";
	label hlp "HELP:Classes are Geometry,Cameras,Helpers,Shapes..." align:#left
	on findname entered nm do (ver = nm)
	
	--FIND--------------------------
	on findok pressed do
	(
		q=#()
		obfield = execute obtype.text
		for i in obfield do
		(
			if matchPattern i.name pattern:("*" + ver+ "*") then
			(
			append q i;
			)
		)
		
		if (q[1]!=undefined) then
		(
			format "\n\n\n\RESULTS:\n"
			append a "\n"
			for s = 1 to q.count do
			(
			format "% = % \n" s q[s]
			append a ("-" + q[s].name)
			append a "; \n"
			)
			txt = "Results:                            " + a
			actionMan.executeAction 0 "40472"
			messagebox txt
		)
		else (messagebox "No results!" beep:0)
	)
	
	
	--SELECT-------------------------
	on selok pressed do
	(
		q=#()
		obfield = execute obtype.text
		for i in obfield do
		(
			if matchPattern i.name pattern:("*" + ver+ "*") then
			(
				if (i !=undefined) do
				(
				append q i;
				)
			)
		)
		select q;
	)
	
	--UNHIDE-------------------
	on unhideok changed stt do
	(
		q=#()
		obfield = execute obtype.text
		for i in obfield do
		(
			if matchPattern i.name pattern:("*" + ver+ "*") then
			(
				if (i !=undefined) do
				(
				append q i;
				)
			)
		)
		for k = 1 to q.count do
		(
			if (unhideok.checked== true) then
			(
				unhideok.text = "Hide!"
				unhide q[k]
			)
			else
			(
				unhideok.text = "Unhide!"
				hide q[k]
			)
		)
		
	)
)
createdialog findObj 300 100
)
