[Closed] (noob) How to check if object exists in scene
Hello Everyone
I’m creating a button that looks for a specific object. If the object does not exist, it gives an error message. Right now this is what I have:
(
if selection.count == 0 then messagebox "Error" beep:true title:"No Rig in Scene"
else
bip01select = select $Bip01
)
What is doing right now, is when I don’t have that object selected, it displays that messagebox, obviously because nothing is selected. So how do I check to see if the bip file exists?
Thanks in Advance
I’m sorry for the stupid question… but Where would I put this code at?
Thank you so much for the reply!
You’re trying to find an object by its name, right. So when the button’s pressed all you have to do is name that object with:
$the_name_of_the_object_youre_looking_for
and if it == undefined then it’s not in the scene. If it is defined, now you can do with it what you want.
on buttonpressed do (
obj = $My_special_object
if obj == undefined then messagebox “Error” beep:true title:“No Rig in Scene”
else {do what you gotta do}
)
But, what happens if someone changes the name of the object? You’re in trouble.
Thank you so much!!! I really appreciate your help. This script is for work and for the current project we are doing, we leave Bip01 as default. When time comes of actually changing the default name, hopefully I won’t be as green with maxscripting as I am right now