# How To: Select invisible vertices and turn visibility ON on selected vertices

**URL:** <https://forum.techsoft3d.com/t/how-to-select-invisible-vertices-and-turn-visibility-on-on-selected-vertices/3042>\
**Category:** HOOPS Visualize Desktop\
**Tags:** learn, knowledge-base, how-to\
**Created:** [December 14, 2023, 11:58pm UTC](https://forum.techsoft3d.com/t/how-to-select-invisible-vertices-and-turn-visibility-on-on-selected-vertices/3042 "2023-12-14T23:58:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.techsoft3d.com/u/simon)\
**Post date:** [December 14, 2023, 11:58pm UTC](https://forum.techsoft3d.com/t/how-to-select-invisible-vertices-and-turn-visibility-on-on-selected-vertices/3042/1 "2023-12-14T23:58:42Z")

</div>

This is sample code on how to select invisible vertices and turn ON selected vertices. (3DF)

```auto
// only select vertices
    HC_Open_Segment_By_Key(m_pHView->GetModelKey()); {
            HC_Set_Selectability("faces=off,vertices=!on,edges=off");
			HC_Set_Visibility("vertices=off");
    } HC_Close_Segment();

    m_pHView->Update();

// sub-entity selection
    HC_Open_Segment_By_Key(m_pHView->GetViewKey()); {
        HC_Set_Heuristics("selection level = entity, no related selection limit, no internal selection limit");

// select top half of screen
        int count = HC_Compute_Selection_By_Area(".", "./scene/overwrite", "v", -1, 1, 0, 1);

        if (count > 0)
        {

            HC_KEY selectionKey = -1;
            HC_Show_Selection_Elements_Coun(&selectionKey, &count);

            int *vertex1 = new int[count];
            int *vertex2 = new int[count];
            int *faces = new int[count];

            for (int i = 0; i < count; i++) {
                vertex1[i] = -1;
                vertex2[i] = -1;
                faces[i] = -1;
            }
            HC_Show_Selection_Elements(&selectionKey, &count, vertex1, vertex2, faces);

            // create a list of selected vertices			
            int found = 0;
            int *highlight_vertex_list = new int[count];

            // Iterate through vertex1
            // Compare vertex2 to determine if vertices is selected

            // See Link on how to identify selected vertices/edges/faces //https://docs.techsoft3d.com/3df/latest/api_ref/3dgs/hc__proto_8h.html#_CPPv426HC_Show_Selection_ElementsP3KeyPiA_iA_iA_i
            int ii=0;
            for (ii = 0; ii < count; ii++)

            {            
                if (vertex2[ii] == -1)
                {
                    highlight_vertex_list[found] = vertex1[ii];
                    found++;
                }
            }

            // visibility array, initialize to 1
            char* visbility_on = new char[found];
            std::fill(visbility_on, visbility_on + found, (char)1);
            HC_MSet_Specific_Vertex_Vis(selectionKey, found, highlight_vertex_list, visbility_on);

            // highlight array, initialize to 0 (black)
            int color_size = found * 3;
            float* highlight_vertex_color = new float[color_size];
            memset(highlight_vertex_color, 0, sizeof(float) * color_size);
            HC_MSet_Specific_Vertex_Colors_By_Value(selectionKey, "vertex", found, highlight_vertex_list, "RGB", highlight_vertex_color);

            // delete all dynamic arrays
            delete[] vertex1;
            delete[] vertex2;
            delete[] faces;
            delete[] visbility_on;
            delete[] highlight_vertex_color;

            m_pHView->Update();

        }
        
    } HC_Close_Segment();

```

**LINK:**

[HC\_Show\_Selection\_Elements](https://docs.techsoft3d.com/3df/latest/api_ref/3dgs/hc__proto_8h.html#_CPPv426HC_Show_Selection_ElementsP3KeyPiA_iA_iA_i)

Video:

![2023-12-14_15-54-11](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/2X/5/5dac71a2e6f3e4fed484198bae906ea02eef6a67.gif)
