How to set leader attachment position to surface
- November 26, 2021
- 1 reply
- 2684 views
Hello everyone,
I create leader note , for that I passed surface selection with view and pointed , but still It goes outside the view , please help me to resolve the issue.
I shared the code for your reference.
ProError ProTestDrawingNoteWithLeader(ProDrawing drawing,ProSolid solid, ProCharLine str, ProCharLine str1, ProView isoView, ProSurface surf, ProVector noteLocation)
{
ProError status;
ProDtlnotedata ndata;
ProDtlnoteline line;
ProDtlnoteline line1;
ProLine wstr;
ProLine wstr1;
ProDtlnotetext text;
ProDtlnotetext text1;
double height = 6;
ProDtlnote note;
ProDtlattach attach, leader;
ProBoolean isShown;
ProStringToWstring(wstr, str);
ProStringToWstring(wstr1, str1);
status = ProDtlnotedataAlloc(drawing, &ndata);
status = ProDtlnotetextAlloc(&text);
status = ProDtlnotetextHeightSet(text, height);
status = ProDtlnotetextWidthSet(text, 0.8);
status = ProDtlnotetextSlantSet(text, 0.0);
status = ProDtlnotetextThicknessSet(text, 0.0);
status = ProDtlnotetextAlloc(&text1);
status = ProDtlnotetextHeightSet(text1, height);
status = ProDtlnotetextWidthSet(text1, 0.8);
status = ProDtlnotetextSlantSet(text1, 0.0);
status = ProDtlnotetextThicknessSet(text1, 0.0);
status = ProDtlnotetextStringSet(text, wstr);
status = ProDtlnotetextStringSet(text1, wstr1);
status = ProDtlnotelineAlloc(&line);
status = ProDtlnotelineAlloc(&line1);
status = ProDtlnotelineTextAdd(line, text);
status = ProDtlnotelineTextAdd(line1, text1);
status = ProDtlnotedataLineAdd(ndata, line);
status = ProDtlnotedataLineAdd(ndata, line1);
ProModelitem modelItem;
status = ProSurfaceToGeomitem(solid, surf, (ProGeomitem*)&modelItem);
ProSelection surfSel;
status = ProSelectionAlloc(NULL, (ProModelitem*)&modelItem, &surfSel);
ProSelection p_sel;
status = ProSelectionAlloc(NULL, (ProModelitem*)&modelItem, &p_sel); //ProArrayAlloc(1, sizeof(ProSelection), 1, (ProArray*)&p_sel);
status = ProSelectionViewSet(isoView,&p_sel);
ProGeomitemdata *srfData;
status = ProSurfaceDataGet(surf, &srfData);
ProContour *surface_counter;
ProEdge *edges;
status = ProUtilCollectSurfaceContours(surf, &surface_counter);
status = ProUtilCollectContourEdges(surf, surface_counter[0], &edges);
ProVector start_point;
ProVector end_Point;
ProEnttype type;
ProVector deriv1;
ProVector deriv2;
ProVector direction;
status = ProEdgeXyzdataEval(edges[0], 0.0, start_point, deriv1, deriv2, direction);
status = ProSelectionPoint3dSet(start_point, &p_sel);
status = ProDtlattachAlloc(PRO_DTLATTACHTYPE_FREE, isoView, noteLocation, NULL, &attach);
status = ProDtlnotedataAttachmentSet(ndata, attach);
status = ProDtlattachAlloc(PRO_DTLATTACHTYPE_PARAMETRIC, NULL, NULL,p_sel, &leader);
status = ProDtlnotedataLeaderAdd(ndata, leader);
status = ProDtlnoteCreate(drawing, NULL, ndata, ¬e);
status = ProDtlnotedataDisplayedSet(ndata, PRO_B_TRUE);
status = ProDrawingViewRegenerate(drawing, isoView);
status = ProAnnotationIsShown((ProAnnotation*)¬e, drawing, &isShown);
if (isShown == PRO_B_FALSE)
{
status = ProAnnotationShow((ProAnnotation*)¬e, NULL, isoView);
}
status = ProDtlnotedataFree(ndata);
status = ProDtlnotetextFree(text);
status = ProDtlattachFree(attach);
status = ProDtlattachFree(leader);
return (status);
}

