Getting nodes in a ICEtree

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
gustavoeb
Moderator
Posts: 587
Joined: 21 Jul 2010, 00:33
Skype: gustavoboehs

Getting nodes in a ICEtree

Post by gustavoeb » 09 Jul 2012, 20:42

Im trying to get get a collection of nodes in a ICEtree and look through them individually. I can get a collection with 4 items, but when I try to access the elements individually I get nothing... Any ideas?

Code: Select all

oNode = xsi.Dictionary.GetObject("PolyIsland_Control.pointcloud.ICEtree")
oNode = oNode.NestedObjects
log(oNode.Count)
returns

Code: Select all

# INFO : 4

Code: Select all

oNode = xsi.Dictionary.GetObject("PolyIsland_Control.pointcloud.ICEtree")
oNode = oNode.NestedObjects
log(oNode.Item)
returns

Code: Select all

# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 9, in <module>
#     log(oNode.Item(1))
# TypeError: 'NoneType' object is not callable
#  - [line 9]
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

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

Re: Getting nodes in a ICEtree

Post by xsisupport » 09 Jul 2012, 21:08

I would use ICETree.Nodes
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

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

Re: Getting nodes in a ICEtree

Post by xsisupport » 09 Jul 2012, 21:31

And to access the actual NestedObjects of an ICETree, don't use the Item method.

Code: Select all

from sipyutils import si			# win32com.client.Dispatch('XSI.Application')
from sipyutils import log		# LogMessage

si = si()

n = si.Dictionary.GetObject( "pointcloud.pointcloud.ICETree" )

x = n.NestedObjects.Item
log( x )
# INFO : None

x = n.NestedObjects( 0 )
log( x )
# INFO : pointcloud.pointcloud.ICETree.Name

for x in n.NestedObjects:
	log( x )
# INFO : pointcloud.pointcloud.ICETree.Name
# INFO : pointcloud.pointcloud.ICETree.DescendantNodes
# INFO : pointcloud.pointcloud.ICETree.port1

In Python, we often avoid using Item.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
gustavoeb
Moderator
Posts: 587
Joined: 21 Jul 2010, 00:33
Skype: gustavoboehs

Re: Getting nodes in a ICEtree

Post by gustavoeb » 09 Jul 2012, 21:51

Thank you very much Stephen!

IT WORKS!
Gustavo Eggert Boehs
Blog: http://www.gustavoeb.com.br/

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests