NX/UG 二次开发 获取注释信息
//获取注释信息
int CmoldingSinglePieceAutoImportSheetDlg::GetLayerAllNotes(vector<string>& notes, tag_t partTag)
{
Part* wp = dynamic_cast<Part*>(NXObjectManager::Get(partTag));
NXOpen::Annotations::NoteCollection* col = wp->Notes();
int stat = 0;
for (NXOpen::Annotations::NoteCollection::iterator it = col->begin(); it != col->end(); it++)
{
tag_t ord_tag = (*it)->Tag();
int type = 0, subtype = 0;
stat = (UF_OBJ_ask_type_and_subtype(ord_tag, &type, &subtype));
if (stat) {
return -1;
}
if (type == UF_drafting_entity_type || subtype == UF_draft_note_subtype)
{
int search_mask[4];
int cycle_flag = 0;
int ann_data[10] = { 0 };
int ann_data_type = 0, ann_data_form = 0, num_segments = 0;
double ann_origin[2] = { 0 }, radius_angle = 0;
stat = (UF_DRF_ask_ann_data(&ord_tag, search_mask, &cycle_flag, ann_data, &ann_data_type, &ann_data_form,
&num_segments, ann_origin, &radius_angle));
if (stat) {
return -1;
}
char* cr3 = NULL;
for (int i = 0; i < num_segments; i++)
{
//读取注释
int ip1 = i+1, ir4 = 0, ir5 = 0;
cr3 = NULL;
stat = (UF_DRF_ask_text_data(ip1, ann_data, &cr3, &ir4, &ir5));
//cout << cr3 << " ir4 " << ir4 << " len: " << ir5 << ln;
if (stat) {
return -1;
}
}
UF_free(cr3);
}
}
return 0;
}