Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Here is the solution....ENJOY
ProError NoteCreate(string strCSYSName,vector<string> vecnotetext,double xoffset,double yoffset,double* NotePosY)
{
ProError status = PRO_TK_GENERAL_ERROR;
ProDtlnotedata objNoteData;
status = ProDtlnotedataAlloc (_maindrwmdl, &objNoteData);
ProName pcsysname;
ProStringToWstring(pcsysname,(char*)strCSYSName.c_str());
ProSelection objSelectionObjs;
ProModelitem pmcsys;
status = ProModelitemByNameInit(_mainasmmdl,PRO_CSYS,pcsysname,&pmcsys);
ProIdTable idtbl;
for(int i=0;i<25;i++)
{
idtbl[i] = -1;
}
ProAsmcomppath asmpath;
ProAsmcomppathInit((ProSolid)_mainasmmdl,idtbl,0,&asmpath);
status = ProSelectionAlloc(&asmpath,&pmcsys,&objSelectionObjs);
status = ProSelectionViewSet(_view,&objSelectionObjs);
ProGeomitemdata *gdata;
status = ProGeomitemdataGet(&pmcsys,&gdata);
status = ProSelectionPoint3dSet(gdata->data.p_csys_data->origin,&objSelectionObjs);
ProVector objLeaderLocationFrmAsm;
status = GetCoordSelection(objSelectionObjs,objLeaderLocationFrmAsm,xoffset,yoffset);
if(strCSYSName!="B_PLATFORM_1")
{
if(objLeaderLocationFrmAsm[1]-*NotePosY<27)
{
objLeaderLocationFrmAsm[1] = objLeaderLocationFrmAsm[1]+(27-(objLeaderLocationFrmAsm[1]-*NotePosY));
}
}
if(objLeaderLocationFrmAsm[1]>800.0 && *NotePosY<775.0)
{
objLeaderLocationFrmAsm[1] = 800;
}
*NotePosY = objLeaderLocationFrmAsm[1];
ProDtlattach objDtlAttch;
status = ProDtlattachAlloc(PRO_DTLATTACHTYPE_FREE,_view,objLeaderLocationFrmAsm,NULL,&objDtlAttch);
status =ProDtlnotedataAttachmentSet(objNoteData,objDtlAttch);
ProDtlnoteline* objArrDtlNoteLines;
status = ProTestNoteTextGet (&objArrDtlNoteLines,vecnotetext);
status = ProDtlnoteldataLinesSet (objNoteData, objArrDtlNoteLines);
status = ProArrayFree ((ProArray*)&objArrDtlNoteLines);
ProDtlattach objLeader;
status = ProDtlattachAlloc(PRO_DTLATTACHTYPE_PARAMETRIC, NULL, NULL, objSelectionObjs,&objLeader);
status = ProDtlnotedataLeaderAdd(objNoteData, objLeader);
ProDtlnote objNote;
status = ProDtlnotedataDisplayedSet(objNoteData,PRO_B_TRUE);
status = ProDtlnoteCreate (_maindrwmdl, NULL, objNoteData, &objNote);
status = ProDtlattachFree(objDtlAttch);
status = ProDtlnotedataFree(objNoteData);
return status;
}