How to extract information from the Define Shape

float const clipped[] = {3,  8, 1,  0, 1,  0, 1,  0, 1, 0, 0,  0,  1, 1, -1, 0, 0,  0,  1, 1, -1, 0, -1, 0, 1, 0,
                         -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, -1, -1, 1, 0, 0,  0, -1, -1, 1, 0, 1,  0, -1, 0, 0};
HC_Define_Shape("clipped", countof(clipped), clipped);

HC_Open_Segment("clipped");
HC_Set_Text_Font("background=shape=clipped");
HC_Insert_Text(-0.8, 0.8, 0, "corner trimmed box");
HC_Close_Segment();

I saw an example like this in the document. But I wonder what I should do if I want to search and see the contents of Defined Shape after saving it.

According to the document, there are functions such as HC_Show_Shape_Size or HC_PShow_Net_Shape, so I would appreciate it if you could tell me how to use it.

Thank you for your help all the time.

Unfortunately, the documentation around the Shape API is lacking. Here’s a code snippet for searching and extracting (or “showing”) shape data.

std::set<std::string> found;

HC_Open_Segment(seg);
{
    HC_Begin_Shape_Search();
    {
        int count = 0;
        HC_Show_Shape_Count(&count);
        if (count > 0) {
            std::vector<float> data;
            char name[1024];
            while (HC_Find_Shape(name)) {
                int size = 0;
                HC_Show_Shape_Size(name, &size);
    
                data.resize(size);
                HC_Show_Shape(name, data.data());
    
                found.insert(name);
            }
        }
    }
    HC_End_Shape_Search();
}
HC_Close_Segment();

This should help you understand how to use this part of the API.

1 Like

Thank you very much. ^^