Once upon a time the Entity.Selected property

Refers to Eyeshot 10.0.817 and greater.



Since Eyeshot version 1, entity selection was controlled by Entity.Selected property. The first evolution happened in Eyeshot version 9, where we introduced the ability to select object sub-items, like vertices, edges or faces (see the selectionFilterType enum). Even this new feature, by the way, did not resolve the ability to select items inside a specific assembly component instance. A real world example could be a mechanical part with many instances of the same bolt on it, where you pretend to select a face of a specific bolt instance. This is the reason why in Eyeshot version 10 we invite all of our customers to get familiar with the following new selection API.


Entity.SetSelection(status, Stack<BlockReference> parents = null)
Entity.GetSelection(Stack<BlockReference> parents = null) 
Entity.ClearSelectionForAllInstances() // clears entity selection for all instances

When the parents parameter is omitted, you select the actual entity (top level, no block/block reference involved). When the parents parameter is used with a chain of parents instead, you select the entity inside the specified block reference instance. The same applies to the sub-items selection below.


Faces (Solid3D/Mesh/Solid)

SetFaceSelection(faceIndex, status, Stack<BlockReference> parents = null)
GetFaceSelection (faceIndex, Stack<BlockReference> parents = null)
ClearFacesSelection(Stack<BlockReference> parents = null) // clears faces selection for top level or nested instance
ClearFacesSelectionForAllInstances() // clears faces selection (for all shells) for all instances

Please note that Mesh and Solid faces can be selected only interactively.

Edges (Solid3D only)

Solid3D.SetEdgeSelection(edgeIndex, status, Stack<BlockReference> parents = null)
Solid3D.GetEdgeSelection(edgeIndex, Stack<BlockReference> parents = null)
Solid3D.ClearEdgesSelection(Stack<BlockReference> parents = null) // clears edges selection for top level or nested instance
Solid3D.ClearEdgesSelectionForAllInstances() // clears edges selection for all instances

Vertices (Solid3D only)

Solid3D.SetVertexSelection(vertexIndex, status, Stack<BlockReference> parents = null)
Solid3D.GetVertexSelection(vertexIndex, Stack<BlockReference> parents = null)
Solid3D.ClearVerticesSelection(Stack<BlockReference> parents = null) // Clears vertices selection for top level or nested instance
Solid3D.ClearVerticesSelectionForAllInstances() // Clears vertices selection for all instances


Assembly Selection Mode

When you are dealing with a scene graph or an assembly of components, another selection option is available: branch or leaf (see assemblySelectionType enum). The former option allows the selection of the specified component instance and all its children. The latter allows the selection of the single component at the bottom of the chain.

You can experiment these options in the AssemblyBrowser source code sample.


SelectionChanged Event

When listening to ViewportLayout.SelectionChanged event, it is possible to get the information about the selected Entity/Face/Edge/Vertex in the following way:

private void viewportLayout1_SelectionChanged(object sender, ViewportLayout.SelectionChangedEventArgs e)
    Console.WriteLine("Added items");

    for (int i = 0; i < e.AddedItems.Count; i++)

    Console.WriteLine("Removed items");

    for (int i = 0; i < e.RemovedItems.Count; i++)

private static void PrintItem(ViewportLayout.SelectedItem sItem)
    Console.WriteLine("Parents: ");

    foreach (var parent in sItem.Parents)

    if (sItem is ViewportLayout.SelectedSubItem)
        if (sItem is ViewportLayout.SelectedFace)
            var selectedFace = (ViewportLayout.SelectedFace) sItem;

            Console.WriteLine("ShellIndex: " + selectedFace.ShellIndex);
            Console.WriteLine("Face: " + selectedFace.Index);
        else if (sItem is ViewportLayout.SelectedEdge)
            var selectedEdge = (ViewportLayout.SelectedEdge) sItem;

            Console.WriteLine("Edge: " + selectedEdge.Index);
        else if (sItem is ViewportLayout.SelectedVertex)
            var selectedVertex = (ViewportLayout.SelectedVertex) sItem;

            Console.WriteLine("Vertex: " + selectedVertex.Index);


Selection Modes

Let's close this article doing a quick recap of available selection modes. Please note that sub-item selection is available only for graphical selection modes.


SelectByPick Entity selection by pick. A single random item crossing the pick box.
SelectByBox Entity selection by box. All items crossing the selection box.
SelectByBoxEnclosed Entity selection by box on enclosed items only. All items entirely enclosed in the selection box.
SelectByPolygon Entity selection by polygon. All items crossing the selection polygon.
SelectByPolygonEnclosed Entity selection by polygon on enclosed only. All items entirely enclosed in the selection polygon.



SelectVisibleByPick Entity selection by pick on visible only. The single item (closest to the user) crossing the pick box.


Entity selection by box on visible only. All items (closest to the user) crossing the selection box.
SelectVisibleByPolygon Entity selection by polygon on visible only. All items (closest to the user) crossing the selection polygon.
SelectVisibleByPickDynamic Entity selection by pick on visible only. The single item (closest to the user) crossing the pick box. Performed dynamically during the mouse movement.


As you can imagine setting Entity.Selected as true for a block definition entities does not make much sense. It will result in the selection of the same entity in each block instance of the 3D scene.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • I Try to select a single edge within a composite curve.

    Is there any way to do this, or do I have to add each sub element from the composition curve one by one to the view port?

  • Hi Stefan,

    Sub-item selection on composite curves is not supported, sorry.

  • Hi,

       how to get normal vector of selectedFace?

  • If you are talking about Brep.Face, you simply need to check if the Brep.Face.Surface is a PlanarSurf type and if it is, check the Plane Z axis.

  • Hi Alberto

    If I set Entity.SetSelection(status, Stack<BlockReference> parents = null) the SelectionChanged of the workspace/design is never triggered?

    I have tried different types of assemblySelectionType enum and other selection enums combinations, but the SelectionChanged event is never triggered from code?

    Also not in the AssemblyDemo ?

    How can I manually change selection from code (tree view), so its basically the same as the user click in the view, and the SelectionChanged event is raised?




Please sign in to leave a comment.