Unless I missed something in the docs, you have to go through the old NestedObjects routine to do it.
Here’s a JScript version. Python to follow soon…
var n = Selection(0);
oEnum = new Enumerator( get_comments(n) ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
var oComment = oEnum.item() ;
LogMessage( oComment.Parameters("Text").Value );
}
//--------------------------------------
// Find comments
// Works with an ICENode or a compound
//--------------------------------------
function get_comments( node )
{
var oComments = new ActiveXObject( "XSI.Collection" );
if ( ClassName(node) == "ICENode" )
{
var oComment = node.NestedObjects("ICE Comment");
if ( oComment != null ) oComments.Add( oComment );
}
else if ( ClassName(node) == "ICECompoundNode" )
{
var nested = Dictionary.GetObject( node.FullName + ".ContainedNodes" ).NestedObjects;
oEnum = new Enumerator( nested ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
var oItem = oEnum.item() ;
if ( oItem.Type == "ICETreeComment" )
{
oComments.Add( oItem );
}
}
}
return oComments;
}
from siutils import si # Application
from siutils import sidict # Dictionary
from siutils import sisel # Selection
from siutils import log # LogMessage
from siutils import disp # win32com.client.Dispatch
from siutils import C # win32com.client.constants
def get_comments( node ):
oComments = disp( "XSI.Collection" )
if si.ClassName(node) == "ICENode":
oComment = node.NestedObjects("ICE Comment")
if ( oComment != None ):
oComments.Add( oComment );
elif si.ClassName(node) == "ICECompoundNode":
nested = sidict.GetObject( node.FullName + ".ContainedNodes" ).NestedObjects
for o in nested:
if o.Type == "ICETreeComment":
oComments.Add( o )
return oComments
n = sisel(0)
# Get comments and print out the text
for c in get_comments(n):
log( c.Parameters("Text").Value )
