Yes, this old chestnut…I thought I had posted this ages ago, but I don’t see in the archives, so:
If you want to check if an object exists, and you don’t want to deal with any error handling, then do it this way:
from sipyutils import disp # win32com.client.Dispatch def objExists( name ): c = disp( "XSI.Collection" ) c.Items = name return not( c.Count == 0 ) print 'Object does exist' if objExists( "XSI_Man.geom" ) else 'Does not exist'
siget = lambda name: Application.Dictionary.GetObject(name, False)
print ‘Object does exist’ if siget(“XSI_Man.geom”) else ‘Does not exist’
Funny that I never realized that argument was there; I always thought we talked about adding it one day but never did