Get Point selection tag center
-
Hi Guys:
I don't see the point position data that can be returned in "gettagdata",I hope I can get the center position of the selected point or point group. At present, I have set a link window in the dialog box. I hope I can drag my point group label to reach the link, and then calculate a center according to the linked point group (similar to forming a new bound and then getting the center). Plz
Thank you```
.....case IDC_LINKBOX2 :
{
GePrint("aaa"_s);
// Test can get response
break;
} -
Hi,
you must retrieve the BaseSelect from the tag with GetBaseSelect and check every point if they are selected or not and calculate the mean.
You also must retrieve the object the tag is attached to and the point positions. This can be done with GetObject and GetPointR. In that case, I am using GetPointR because i do not want to modify the values.// get point selection tag LinkBoxGui* linkGui = static_cast<LinkBoxGui*>(FindCustomGui(IDC_LINKBOX2, CUSTOMGUI_LINKBOX)); if (linkGui == nullptr) return false; BaseDocument* doc = GetActiveDocument(); if (doc == nullptr) return false; SelectionTag* selectionTag = (SelectionTag*)linkGui->GetLink(doc); if (selectionTag == nullptr) { ApplicationOutput("the field is empty"); return true; } // stop if the selection tag is not a point selection but we still return true if (!selectionTag->IsInstanceOf(Tpointselection)) return true; PointObject* op = ToPoly(selectionTag->GetObject()); if (op == nullptr) return false; const Vector* padr = op->GetPointR(); const Int32 pointCount = op->GetPointCount(); BaseSelect* selection = selectionTag->GetBaseSelect(); // use the LminMax class to retrieve selection information // calculate the mean of all points Vector mean; for (Int32 pointIndex = 0; pointIndex < pointCount; pointIndex++) { if (selection->IsSelected(pointIndex)) mean += padr[pointIndex]; } mean /= selection->GetCount(); ApplicationOutput(" mean is @", mean); return true; break;
Cheers,
Manuel -
@m_magalhaes Hi,m_magalhaes, I want to call your name again, because the last question is also your answer and has perfectly solved my problem. You are my God. Thank you very much.
Can I ask another question? Last night, I found that my tag name may be unclear. I want to use my own name. But gettagdata is not a member of baselist2d. I tried to browse the API, but I couldn't find the answer. For example, findcustomgui, which can be clearly known in the SDK, belongs to getdialog
-
You mean GetTagDataR or GetTagDataW?? They are part of BaseObject.
I am not sure to follow you.
Cheers,
Manuel -
This post is deleted! -
This post is deleted! -
@m_magalhaes Thank you, I think I understand