If.....then.......

how can i make it search the name in the selected objects instead of the entire scene?
the script searches the entire scene i want to search only the selected objects for G1.

thanks in advance.

on insert pressed do
(
objVar = $G1
(
if isvalidnode objVar then
(
Print "1"
)
else
(
Print "2"
)
)
)

Comments

Comment viewing options

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

objToFind = "ObjName" objVar

	objToFind = "ObjName"
	objVar = $G1
	(
		if isvalidnode objVar and objVar.children.count != 0 do
		(
			node = for o in objVar.children where o.name == objToFind collect o
			if node.count != 0 then
			(
				Print "1"
			)
			else
			(
				Print "2"
			)
		)
	)

bga

Mrjacks2o's picture

Thanks but

Hi Thanks for the replay but its not working for me.
it keeps printing 2 if the object is selected or not. how can i have it print "1" if selected and if the name = G1 else print "2"

rollout test "Test"
(
listBox testList items:#("Item 1","Item 2")
button addToList "Add Item To End Of List" width:180
button insertToList "Insert Before Current Item" width:180
button removeFromList "Remove Current Item" width:180

on addToList pressed do
testList.items = append testList.items "test"
on insertToList pressed do
(
objToFind = "ObjName"
objVar = $G1
(
if isvalidnode objVar and objVar.children.count != 0 do
(
node = for o in objVar.children where o.name == objToFind collect o
if node.count != 0 then
(
Print "1"
)
else
(
Print "2"
)
)
)
)

on removeFromList pressed do
(
testList.items = deleteItem testList.items testList.selection
)
)
createDialog test 200 220

pixamoon's picture

`

try those:

for i = 1 to selection.count do (
	if selection[i].name == "G1" do (
		print "1"
		exit
	)
	if i == selection.count do print "2"
)

or this one:
(it also collect objects with specified name)

someArray = for o in selection where o.name == "G1" collect o
if someArray.count > 0 then print "1" else print "2"
Mrjacks2o's picture

Great!!! thank you both!!!!

worked great.

Comment viewing options

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