ICE Tree traversal - [solved]
-
Hirazi Blue
- Administrator
- Posts: 5113
- Joined: 04 Jun 2009, 10:15
ICE Tree traversal - [solved]
I was trying to do some Pythonesk traversal of an ICE Tree using a slight adaptation of this script. This works, but doesn't seem to take into account the difference between nodes that are part of a branch that is connected to the ICE Tree node and nodes that are just laying in the ICE Tree View doing nothing. So now my question is, working from any given node, what would be the easiest way to test if it's part of a connected branch or not?

Stay safe, sane & healthy!
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: ICE Tree traversal - unconnected branches
ICENode.IsConnected ?
-
Hirazi Blue
- Administrator
- Posts: 5113
- Joined: 04 Jun 2009, 10:15
Re: ICE Tree traversal - unconnected branches
No, that doesn't get me the result I was looking for exactly, as this returns "True" for nodes in a branch that itself isn't connected to the ICE Tree, if they themselves are connected to another node in such a disconnected branch... Only the node that is/isn't actually connected to the ICE Tree gives the correct result. It does work as a further adaptation of the aforementioned script, as I can use it to "prune" the tree, but my question goes further than that...
So maybe my example (and the title of this thread) was wrong
, as (for what I ultimately want to achieve) I do not want to necessarily start at the root of the ICE Tree, but at any single node in the ICE Tree View.
I'm probably just barking up the wrong tree here (pun intended), but I'm looking for a way to select a single node and decide quickly in a script if it's part of (as in: connected to) the current ICE Tree or merely taking up space in the ICE Tree View, waiting for better times...
;)
So maybe my example (and the title of this thread) was wrong
I'm probably just barking up the wrong tree here (pun intended), but I'm looking for a way to select a single node and decide quickly in a script if it's part of (as in: connected to) the current ICE Tree or merely taking up space in the ICE Tree View, waiting for better times...
;)
Stay safe, sane & healthy!
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: ICE Tree traversal - unconnected branches
I think you'll have to traverse the output ports, checking IsConnected.
To test this snippet, select an ice node in the explorer.
To test this snippet, select an ice node in the explorer.
Code: Select all
var o = Selection(0);
//LogMessage( o.IsConnected );
LogMessage( "test()="+test(o) );
function test( oNode )
{
if ( !oNode.IsConnected )
{
LogMessage( "Not connected" );
return false;
}
else if ( oNode.Type == "ICETree" )
{
LogMessage( "Connected" );
return true;
}
else
{
oEnum = new Enumerator( oNode.OutputPorts ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
var oSelItem = oEnum.item() ;
oEnum1 = new Enumerator( oSelItem.ConnectedNodes ) ;
for (;!oEnum1.atEnd();oEnum1.moveNext() )
{
var oSelItem1 = oEnum1.item() ;
return test( oSelItem1 );
}
}
}
}
-
Hirazi Blue
- Administrator
- Posts: 5113
- Joined: 04 Jun 2009, 10:15
Re: ICE Tree traversal - unconnected branches
Ah, I guess I was truly barking up the wrong (side of the) tree...
Thanks, I will check this out
Thanks, I will check this out
Stay safe, sane & healthy!
-
Hirazi Blue
- Administrator
- Posts: 5113
- Joined: 04 Jun 2009, 10:15
Re: ICE Tree traversal - unconnected branches
repost/edit: I removed the very preliminary resulting plugin from this thread... ;)
Stay safe, sane & healthy!
-
Leo
- Posts: 128
- Joined: 04 Jun 2009, 15:06
Re: ICE Tree traversal - unconnected branches
Don't be so insecure about your work, just post what you got, it was working fine wasn't it?