1 NX11+VS2013 2 3 #include <uf.h> 4 #include <uf_ui.h> 5 #include <uf_tabnot.h> 6 #include <NXOpen/Part.hxx> 7 #include <NXOpen/PartCollection.hxx> 8 #include <NXOpen/Session.hxx> 9 #include <NXOpen/Annotations_TableSectionCollection.hxx> 10 #include <NXOpen/Annotations_AnnotationManager.hxx> 11 #include <NXOpen/FontCollection.hxx> 12 13 14 UF_initialize(); 15 16 //创建表格注释 17 Annotations::TableSection *nullAnnotations_TableSection(NULL); 18 Annotations::TableSectionBuilder *tableSectionBuilder1; 19 tableSectionBuilder1 = workPart->Annotations()->TableSections()->CreateTableSectionBuilder(nullAnnotations_TableSection); 20 NXOpen::Point3d TablePoint(194.0, 17.0, 0.0); 21 tableSectionBuilder1->Origin()->SetOriginPoint(TablePoint); 22 tableSectionBuilder1->SetNumberOfColumns(2); 23 tableSectionBuilder1->SetNumberOfRows(2); 24 tableSectionBuilder1->SetRowHeight(20.0); 25 tableSectionBuilder1->SetColumnWidth(50); 26 tableSectionBuilder1->Commit(); 27 NXObject *nXObject1; 28 nXObject1 = tableSectionBuilder1->Commit(); 29 tableSectionBuilder1->Destroy(); 30 31 //section转tag 32 tag_t TabularNote = NULL_TAG; 33 UF_TABNOT_ask_tabular_note_of_section(nXObject1->Tag(), &TabularNote); 34 35 //获取第一行的Tag 36 tag_t Row0Tag = NULL_TAG; 37UF_TABNOT_ask_nth_row (TabularNote, 0 , & Row0Tag); 38 is 39 // Get the second row of the Tag 40 tag_t Row1Tag = NULL_TAG; 41 is UF_TABNOT_ask_nth_row (TabularNote, . 1 , & Row1Tag); 42 is 43 is // get the first column of the Tag 44 is tag_t Column0Tag = NULL_TAG; 45 UF_TABNOT_ask_nth_column (TabularNote, 0 , & Column0Tag); 46 is 47 // Get Tag second column 48 tag_t Column1Tag = NULL_TAG; 49 UF_TABNOT_ask_nth_column (TabularNote, . 1, & Column1Tag); 50 51 is // get first row and first column of cells of the Tag 52 is tag_t Cell0Tag = NULL_TAG; 53 is UF_TABNOT_ask_cell_at_row_col (Row0Tag, Column0Tag, & Cell0Tag); 54 is 55 // obtain a first row, second column cell of the Tag 56 is tag_t Cell1Tag = NULL_TAG; 57 is UF_TABNOT_ask_cell_at_row_col (Row0Tag, Column1Tag, & Cell1Tag); 58 59 // get the second row of the first column of cells the Tag 60 tag_t Cell2Tag = NULL_TAG; 61 is UF_TABNOT_ask_cell_at_row_col (Row1Tag, Column0Tag, & Cell2Tag) ; 62 63 //To obtain a second row in the second column of cells of the Tag 64 tag_t Cell3Tag = NULL_TAG; 65 UF_TABNOT_ask_cell_at_row_col (Row1Tag, Column1Tag, & Cell3Tag); 66 67 // Write text 68 UF_TABNOT_set_cell_text (Cell0Tag, " designer " ); 69 UF_TABNOT_set_cell_text (Cell1Tag, " Lushang Yu " ); 70 71 is // merge the lowermost cell 72 UF_TABNOT_merge_cells (Cell2Tag, Cell3Tag); 73 is 74 // obtain a merged cell line of the Tag 75 tag_t MergeRowTag = NULL_TAG; 76UF_TABNOT_ask_nth_row (TabularNote, . 1 , & MergeRowTag); 77 78 // Get merged cell column of the Tag 79 tag_t MergeColumnTag = NULL_TAG; 80 UF_TABNOT_ask_nth_column (TabularNote, 0 , & MergeColumnTag); 81 82 tag_t MergeCellTag = NULL_TAG; 83 UF_TABNOT_ask_cell_at_row_col (MergeRowTag, MergeColumnTag, & MergeCellTag); 84 85 // write text 86 UF_TABNOT_set_cell_text (MergeCellTag, " the version number: xxxxxxxxxx " ); 87 88 //Retrieving default preferences Cell 89 UF_TABNOT_cell_prefs_t cell_prefs; 90 UF_TABNOT_ask_default_cell_prefs (& cell_prefs); 91 is 92 // set preferences cell 93 int fontIndex1 = workPart-> Fonts () -> AddFont ( " chinesef_fs " , NXOpen :: :: FontCollection TypeNx); // change the font 94 cell_prefs.text_font = fontIndex1; // Font 95 UF_TABNOT_set_cell_prefs (Cell0Tag, & cell_prefs); 96 UF_TABNOT_set_cell_prefs (Cell1Tag, & cell_prefs); 97 UF_TABNOT_set_cell_prefs (MergeCellTag, & cell_prefs); 98 99 // read the contents of the cell 100 char * cell_text; 101 UF_TABNOT_ask_cell_text (Cell0Tag, & cell_text); 102 103 // division string 104 String strCellText = cell_text; 105 String strRight = (strCellText.substr (strCellText.find ( " @ " ) + . 1 , strCellText.find ( " " ))); // extract rvalue 106 String strLift = (strRight.substr ( 0 , strRight.find ( " > " ))); // extract left value 107 108 // print 109 uc1601 (cell_text, . 1 ); 110 111 UF_terminate (); 112 113 Caesar Lushang Yu 114 December 15, 2019
NX secondary development -UFUN read table footnotes UF_TABNOT_ask_cell_text
Guess you like
Origin www.cnblogs.com/nxopen2018/p/12044392.html
Ranking