オブジェクト モデルから選択されているコンポーネントのリストにアクセスする

 
 
 
// C# -- assuming sampled points are selected
CXSIApplication app = new CXSIApplication();
CollectionItem collitem = (CollectionItem)app.Selection[0];
SubComponent subcmp = (SubComponent)collitem.SubComponent;
SampleCollection smplcoll = (SampleCollection)subcmp.ComponentCollection;
app.LogMessage("There are " + smplcoll.Count.ToString() 
	+ " selected samples.", siSeverity.siInfo);
foreach (Sample smpl in smplcoll)
{
	app.LogMessage("Current sample[" + smpl.Index.ToString()
		+ "] (prev:[" + smpl.Navigate(siNavigateComponentType.siPreviousComponent).Index.ToString()
		+ "]; next:[" + smpl.Navigate(siNavigateComponentType.siNextComponent).Index.ToString()
		+ "])", siSeverity.siInfo);
}

// JScript -- assuming control points are selected
var subcmp = Selection(0).SubComponent;
var ctrlpts = subcmp.ComponentCollection;
for( var i=0; i<ctrlpts.Count; i++ ) 
{
	LogMessage( "Position of ctrlpt[" + ctrlpts(i).Index + "]: "
		+ ctrlpts(i).X + "," 
		+ ctrlpts(i).Y + "," 
		+ ctrlpts(i).Z );
}

' VBScript -- assuming vertices are selected
set subcmp = Selection(0).SubComponent
for each vtx in subcmp.ComponentCollection
	LogMessage vtx.Index & " has " & vtx.Nodes.Count & " polygon nodes"
next

# Python -- assuming edges are selected
subcmp = Application.Selection(0).SubComponent
for edg in subcmp.ComponentCollection :
	Application.LogMessage( "edge[%s] is hard: %s" % (edg.Index,edg.IsHard) )

# Perl -- assuming Nurbs subsurfaces are selected
my $subcmp = $Application->Selection(0)->SubComponent;
my $coll = $subcmp->ComponentCollection;
for ( my $i=0; $i<$coll->Count; $i++ ) {
	$Application->LogMessage( $coll->Item($i)->TrimCount );
}