Monday, March 21, 2011

SOFTIMAGE: Starting with IF EXIST

Hi all. We'd like to start this blog with a simple script to check if the given object exists or not. The function returns "True" or "False" depending if it can or can't find the object, so you can check very easily with an IF if what you want is in the scene. VEEEEEEEERY useful, and "A MUST" to have at the top of your scripts.


#CHECK IF AN OBJECT EXISTS

def Exist(input):
    if Application.Dictionary.GetObject ( input, False  ) != None:
        return True
    else:
        return False

#TESTS
if Exist("sphere"):
    print "The object 'sphere' exists in the scene"

if not Exist("cone"):
    print "The object 'cone' doesn't exist in the scene"

No comments:

Post a Comment