Saturday Snippet: Selection, LAST, and SubComponents


Selection.Clear();
var oCube = ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface" );

var n = oCube.ActivePrimitive.Geometry.Points.Count

//SelectGeometryComponents(oCube.Name + ".pnt[1,3,5,LAST]");
Selection.Add( oCube.ActivePrimitive.Geometry.Points(1) );
Selection.Add( oCube.ActivePrimitive.Geometry.Points(3) );
Selection.Add( oCube.ActivePrimitive.Geometry.Points(5) );
Selection.Add( oCube.ActivePrimitive.Geometry.Points(n-1) );

var sel = XSIFactory.CreateActiveXObject("XSI.Collection");           
sel.AddItems(Selection);                  

LogMessage( sel.Count );
// INFO : 1

LogMessage( ClassName( sel(0) ) );
// INFO : CollectionItem

LogMessage( sel(0).Value );
// INFO : cube.pnt[1,3,5,LAST]

n = sel(0).SubComponent.ComponentCollection.Count
LogMessage( sel(0).SubComponent.ComponentCollection(n-1).Index );
// INFO : 7

LogMessage( VBArray( sel(0).SubComponent.ElementArray ).toArray()[n-1] );
// INFO : 7

//LogMessage( sel(0).SubComponent.ComponentCollection );
LogMessage( VBArray( sel(0).SubComponent.ElementArray ).toArray() );

And don’t do this. You’ll have to restart Softimage to get selection working again.

var sel = XSIFactory.CreateActiveXObject("XSI.Collection");           
sel.AddItems(Selection);                  
sel(0).Value = "cube.pnt[7]";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s