Page 1 of 1

Getting nodes in a ICEtree

Posted: 09 Jul 2012, 20:42
by gustavoeb
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]

Re: Getting nodes in a ICEtree

Posted: 09 Jul 2012, 21:08
by xsisupport
I would use ICETree.Nodes

Re: Getting nodes in a ICEtree

Posted: 09 Jul 2012, 21:31
by xsisupport
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.

Re: Getting nodes in a ICEtree

Posted: 09 Jul 2012, 21:51
by gustavoeb
Thank you very much Stephen!

IT WORKS!