/*
This example demonstrates how to query the type of component
that is currently selected. This can be useful if you are
writing a tool that operates only on a specific subcomponent
and you are checking to make sure the correct type of
subcomponent has been selected by the user.
*/
NewScene( null, false );
var root = Application.ActiveSceneRoot;
// For the purposes of this example we are creating
// the cube and adding it to the selection
var box = root.AddGeometry( "Cube", "MeshSurface" );
Selection.Add( box.ActivePrimitive.Geometry.Segments(0) );
// With one facet selected, the Selection.Item property
// returns a CollectionItem from which you can retrieve
// the SubComponent
var first_selected = Selection.Item(0).SubComponent;
Application.LogMessage( Application.ClassName(first_selected) );
// The SubComponent object gives you access to the actual
// interface for the component type via its ComponentCollection
// property (in this case, an Edge object)
var component_collection = first_selected.ComponentCollection;
Application.LogMessage( Application.ClassName(component_collection.Item(0)) );
// Expected results:
//INFO : SubComponent
//INFO : Edge
|