NX二次开发-UFUN询问注释对象的数据UF_DRF_ask_ann_data

  1 //NX9_NXOpenCPP_Wizard1
  2
  3 // Mandatory UF Includes
  4 #include <uf.h>
  5 #include <uf_object_types.h>
  6
  7 // Internal Includes
  8 #include <NXOpen/ListingWindow.hxx>
  9 #include <NXOpen/NXMessageBox.hxx>
 10 #include <NXOpen/UI.hxx>
 11
 12 // Internal+External Includes
 13 #include <NXOpen/Annotations.hxx>
 14 #include <NXOpen/Assemblies_Component.hxx>
 15 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
 16 #include <NXOpen/Body.hxx>
 17 #include <NXOpen/BodyCollection.hxx>
 18 #include <NXOpen/Face.hxx>
 19 #include <NXOpen/Line.hxx>
 20 #include <NXOpen/NXException.hxx>
 21 #include <NXOpen/NXObject.hxx>
 22 #include <NXOpen/Part.hxx>
 23 #include <NXOpen/PartCollection.hxx>
 24 #include <NXOpen/Session.hxx>
 25
 26 #include <uf.h>
 27 #include <uf_ui.h>
 28 #include <uf_drf.h>
 29
 30 // Std C++ Includes
 31 #include <iostream>
 32 #include <sstream>
 33
 34 using namespace NXOpen;
 35 using std::string;
 36 using std::exception;
 37 using std::stringstream;
 38 using std::endl;
 39 using std::cout;
 40 using std::cerr;
 41
 42
 43 //------------------------------------------------------------------------------
 44 // NXOpen c++ test class
 45 //------------------------------------------------------------------------------
 46 class MyClass
 47 {
 48     // class members
 49 public:
 50     static Session *theSession;
 51     static UI *theUI;
 52
 53     MyClass();
 54     ~MyClass();
 55
 56     void do_it();
 57     void print(const NXString &);
 58     void print(const string &);
 59     void print(const char*);
 60
 61 private:
 62     Part *workPart, *displayPart;
 63     NXMessageBox *mb;
 64     ListingWindow *lw;
 65     LogFile *lf;
 66 };
 67
 68 //------------------------------------------------------------------------------
 69 // Initialize static variables
 70 //------------------------------------------------------------------------------
 71 Session *(MyClass::theSession) = NULL;
 72 UI *(MyClass::theUI) = NULL;
 73
 74 //------------------------------------------------------------------------------
 75 // Constructor
 76 //------------------------------------------------------------------------------
 77 MyClass::MyClass()
 78 {
 79
 80     // Initialize the NX Open C++ API environment
 81     MyClass::theSession = NXOpen::Session::GetSession();
 82     MyClass::theUI = UI::GetUI();
 83     mb = theUI->NXMessageBox();
 84     lw = theSession->ListingWindow();
 85     lf = theSession->LogFile();
 86
 87     workPart = theSession->Parts()->Work();
 88     displayPart = theSession->Parts()->Display();
 89
 90 }
 91
 92 //------------------------------------------------------------------------------
 93 // Destructor
 94 //------------------------------------------------------------------------------
 95 MyClass::~MyClass()
 96 {
 97 }
 98
 99 //------------------------------------------------------------------------------
100 // Print string to listing window or stdout
101 //------------------------------------------------------------------------------
102 void MyClass::print(const NXString &msg)
103 {
104     if(! lw->IsOpen() ) lw->Open();
105     lw->WriteLine(msg);
106 }
107 void MyClass::print(const string &msg)
108 {
109     if(! lw->IsOpen() ) lw->Open();
110     lw->WriteLine(msg);
111 }
112 void MyClass::print(const char * msg)
113 {
114     if(! lw->IsOpen() ) lw->Open();
115     lw->WriteLine(msg);
116 }
117
118
119
120
121 //------------------------------------------------------------------------------
122 // Do something
123 //------------------------------------------------------------------------------
124 void MyClass::do_it()
125 {
126
127     // TODO: add your code here
128
129     UF_initialize();
130
131     //创建注释
132     char* TextString[] = {"Caesar卢尚宇"};
133     double Origin3d[3] = {100,100,100};
134     tag_t NoteTag = NULL_TAG;
135     UF_DRF_create_note(1, TextString, Origin3d, 0, &NoteTag);
136
137     //询问注释对象的数据。可以通过将ann_data数组传递给UF_DRF_ask_text_data来读取注释的文本数据(老函数用uc5574读取)
138     int search_mask [4];
139     int cycle_flag = 0;
140     int ann_data [10];
141     int ann_data_type = 0;
142     int ann_data_form = 0;
143     int num_segments = 0;
144     double ann_origin [2];
145     double radius_angle = 0;
146     UF_DRF_ask_ann_data(&NoteTag, search_mask, &cycle_flag, ann_data, &ann_data_type, &ann_data_form, &num_segments, ann_origin, &radius_angle);
147
148     //读取注释
149     int ip1 = 1;
150     char* cr3;
151     int ir4 = 0;
152     int ir5 = 0;
153     UF_DRF_ask_text_data(ip1, ann_data, &cr3, &ir4, &ir5);
154
155     //打印
156     uc1601(cr3,1);
157
158     UF_terminate();
159 }
160
161 //------------------------------------------------------------------------------
162 // Entry point(s) for unmanaged internal NXOpen C/C++ programs
163 //------------------------------------------------------------------------------
164 //  Explicit Execution
165 extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
166 {
167     try
168     {
169         // Create NXOpen C++ class instance
170         MyClass *theMyClass;
171         theMyClass = new MyClass();
172         theMyClass->do_it();
173         delete theMyClass;
174     }
175     catch (const NXException& e1)
176     {
177         UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
178     }
179     catch (const exception& e2)
180     {
181         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
182     }
183     catch (...)
184     {
185         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
186     }
187 }
188
189
190 //------------------------------------------------------------------------------
191 // Unload Handler
192 //------------------------------------------------------------------------------
193 extern "C" DllExport int ufusr_ask_unload()
194 {
195     return (int)NXOpen::Session::LibraryUnloadOptionImmediately;
196 }
197
198
199 Caesar卢尚宇
200 2019年10月3日

原文地址:https://www.cnblogs.com/nxopen2018/p/11619884.html

时间: 2024-10-06 01:19:46

NX二次开发-UFUN询问注释对象的数据UF_DRF_ask_ann_data的相关文章

NX二次开发-UFUN读取工程图注释UF_DRF_ask_text_data

1 //NX9_NXOpenCPP_Wizard1 2 3 // Mandatory UF Includes 4 #include <uf.h> 5 #include <uf_object_types.h> 6 7 // Internal Includes 8 #include <NXOpen/ListingWindow.hxx> 9 #include <NXOpen/NXMessageBox.hxx> 10 #include <NXOpen/UI.h

NX二次开发-UFUN和NXOpen结合开发中Tag_t对象与TaggedObject对象转换方法

1 本文通过举四个例子来告诉大家在NX二次开发过程中会经常用到UFUN和NXOpen结合去开发,在UFUN中我们得到的是Tag_t对象,在NXOpen中得到的是TaggedObject对象,这两个是需要进行转换的.本文主要知识点为:TaggedObject->tag_t() , NXOpen::NXObjectManager::Get(BodyTag1) , feature1->JournalIdentifier()的用法. 2 3 NX11+VS2013 4 5 #include <u

NX二次开发-UFUN获取显示在NX交互界面的对象UF_OBJ_is_displayable

1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_disp.h> 5 #include <uf_obj.h> 6 #include <uf_part.h> 7 8 UF_initialize(); 9 10 //遍历当前显示部件 11 tag_t NextTag = NULL_TAG; 12 int Type1, SubType1; 13 do 14 { 15 NextTag = UF_OBJ_cycle_all

NX二次开发-UFUN工程图表格注释获取某一行的tag函数UF_TABNOT_ask_nth_row

1 NX9+VS2012 2 3 4 #include <uf.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>

NX二次开发-UFUN工程图表格注释获取某一行某一列的tag函数UF_TABNOT_ask_cell_at_row_col

1 NX9+VS2012 2 3 4 #include <uf.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>

NX二次开发-UFUN获取对象的显示属性(图层,颜色,空白状态,线宽,字体,高亮状态)UF_OBJ_ask_display_properties

1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <uf_obj.h> 6 7 UF_initialize(); 8 9 UF_FEATURE_SIGN Sign = UF_NULLSIGN;//设置布尔 10 double Corner_pt[3] = {0.0, 0.0, 0.0};//设置原点 11 char *Edge_Len[3] = {"100", &qu

NX二次开发-UFUN查询对象的类型和子类型UF_OBJ_ask_type_and_subtype

1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_obj.h> 5 #include <uf_modl.h> 6 #include <uf_part.h> 7 8 UF_initialize(); 9 10 //遍历当前显示部件 11 std::vector<tag_t> SolidVector; 12 tag_t ObjectTag = NULL_TAG; 13 int Type, SubType,

NX二次开发-UFUN工程图表格注释检索默认单元格首选项UF_TABNOT_ask_default_cell_prefs

1 NX9+VS2012 2 3 4 #include <uf.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>

NX二次开发-UFUN工程图表格注释写入文本内容UF_TABNOT_set_cell_text

1 NX9+VS2012 2 3 4 #include <uf.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>