Get new instance of a renamed object

Discussions concerning programming of SOFTIMAGE©
iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Get new instance of a renamed object

Post by iamVFX » 28 Mar 2012, 15:20

Is there a way to rename an object and get it as an new instance? For example SetValue returns unicode name without parent model:

Code: Select all

si = Application

si.NewScene()

model = si.CreateModel()
obj = si.GetPrim("Null", "", model)
print type(obj)
# <type 'instance'>

obj = si.SetValue(obj.FullName+".Name", "null_renamed")
print type(obj)
# <type 'unicode'>

# The question is: how to rename object and get as an 'instance'?

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Get new instance of a renamed object

Post by xsisupport » 28 Mar 2012, 16:20

According to the docs, SetValue should return the old parameter value (eg the old name) but it returns the new name. The Name parameter is a string value, so you get back a string.

Anyways...

Code: Select all

si = Application

#si.NewScene()

model = si.CreateModel()
obj = si.GetPrim("Null", "", model)
print type(obj)
# <type 'instance'>

obj1 = si.Dictionary.GetObject( si.SetValue(obj.FullName+".Name", "null_renamed") )
print type(obj1)

print obj == obj1
# False

print obj.IsEqualTo(obj1)
# True
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: Get new instance of a renamed object

Post by iamVFX » 28 Mar 2012, 16:27

Oh, I get it! Thank you, Steve! Again :)