PDA

View Full Version : Get Constraining object via Object model ?


PetrZ
06-16-2008, 01:57 PM
I have little issue when I try to get constraining object, e.g. I create basic spot light from menu (with parent Spot_Root and Direction constrain to Spot_Interest), and I try to get Spot_Interest obj via Direction Constrain:

xsi = Application
log = xsi.LogMessage
null = None
false = 0
true = 1

oObj = xsi.Selection(0)

oCnsColl = oObj.Kinematics.Constraints

if (oCnsColl.Count != 0):
oDirCnsColl = XSIFactory.CreateObject("XSI.Collection")
for oCns in oCnsColl:
if (oCns.Type == "dircns"):
oDirCnsColl.Add(oCns.Constraining)
xsi.LogMessage(str(oCns.Constrained)) #return Spot, what is correct
xsi.LogMessage(str(oCns.Constraining)) #return None when it should return Spot_Interest
xsi.LogMessage(str(oDirCnsColl(0))) #return void text when it should return Spot_Interest and any other index than zero return None Problem is, that this code doesn't work how I assumed. What I'm doing wrong?

(ActivePython-2.4.3.12-win64-x64-nopywin32 + pywin32-207.win64-py2.4 + win xp 64bit)

SebasProulx
06-16-2008, 03:18 PM
"Constraining" doesn't return an object like "Constrained", it returns a collection.

I guess you would need to do:

xsi.LogMessage(str(oCns.Constraining(0)))

PetrZ
06-17-2008, 03:40 AM
Yes it was collection, I just didn't notice it because this None return value.
Thanks