NX二次开发-移除参数,删除所有实体参数,移除所有实体参数代码
//移除参数删除所有实体参数移除所有实体参数代码 // Mandatory UF Includes #include uf.h #include uf_object_types.h // Internal Includes #include NXOpen/ListingWindow.hxx #include NXOpen/NXMessageBox.hxx #include NXOpen/UI.hxx // InternalExternal Includes #include NXOpen/Annotations.hxx #include NXOpen/Assemblies_Component.hxx #include NXOpen/Assemblies_ComponentAssembly.hxx #include NXOpen/Body.hxx #include NXOpen/BodyCollection.hxx #include NXOpen/Face.hxx #include NXOpen/Line.hxx #include NXOpen/NXException.hxx #include NXOpen/NXObject.hxx #include NXOpen/Part.hxx #include NXOpen/PartCollection.hxx #include NXOpen/Session.hxx // Std C Includes #include iostream #include sstream //用户代码 #include uf_modl.h #include uf_obj.h #include uf_part.h using namespace NXOpen; using std::string; using std::exception; using std::stringstream; using std::endl; using std::cout; using std::cerr; //------------------------------------------------------------------------------ // NXOpen c test class //------------------------------------------------------------------------------ class MyClass { // class members public: static Session *theSession; static UI *theUI; MyClass(); ~MyClass(); void do_it(); void print(const NXString ); void print(const string ); void print(const char*); private: BasePart *workPart, *displayPart; NXMessageBox *mb; ListingWindow *lw; LogFile *lf; }; //------------------------------------------------------------------------------ // Initialize static variables //------------------------------------------------------------------------------ Session *(MyClass::theSession) NULL; UI *(MyClass::theUI) NULL; //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ MyClass::MyClass() { // Initialize the NX Open C API environment MyClass::theSession NXOpen::Session::GetSession(); MyClass::theUI UI::GetUI(); mb theUI-NXMessageBox(); lw theSession-ListingWindow(); lf theSession-LogFile(); workPart theSession-Parts()-BaseWork(); displayPart theSession-Parts()-BaseDisplay(); } //------------------------------------------------------------------------------ // Destructor //------------------------------------------------------------------------------ MyClass::~MyClass() { } //------------------------------------------------------------------------------ // Print string to listing window or stdout //------------------------------------------------------------------------------ void MyClass::print(const NXString msg) { if(! lw-IsOpen() ) lw-Open(); lw-WriteLine(msg); } void MyClass::print(const string msg) { if(! lw-IsOpen() ) lw-Open(); lw-WriteLine(msg); } void MyClass::print(const char * msg) { if(! lw-IsOpen() ) lw-Open(); lw-WriteLine(msg); } //------------------------------------------------------------------------------ // Do something //------------------------------------------------------------------------------ void MyClass::do_it() { // 用户代码 //删除所有实体参数 tag_t disp_part_tag, next_tag NULL_TAG, subtype NULL_TAG; int num 0, nm 0; char *feat_type; int type UF_solid_type; // 对象类型 UF_solid_type int ssubtype; uf_list_p_t body_list; UF_MODL_create_list(body_list); disp_part_tag UF_PART_ask_display_part(); //得到当前部件文件标识 UF_OBJ_cycle_objs_in_part(disp_part_tag, type, next_tag); while (next_tag ! NULL_TAG) { num; UF_OBJ_ask_type_and_subtype(next_tag, type, ssubtype); //获得对象类型 if (ssubtype UF_solid_body_subtype) //比较对象类型是否固体 { nm; UF_MODL_put_list_item(body_list, next_tag); //next_tag对象加入到body_list对象列表尾部 } UF_OBJ_cycle_objs_in_part(disp_part_tag, type, next_tag); } if (nm0) { UF_MODL_delete_body_parms(body_list); //删除对象列表所有对象参数 } } //------------------------------------------------------------------------------ // Entry point(s) for unmanaged internal NXOpen C/C programs //------------------------------------------------------------------------------ // Explicit Execution extern C DllExport void ufusr( char *parm, int *returnCode, int rlen ) { UF_initialize();//入口函数 try { // Create NXOpen C class instance MyClass *theMyClass; theMyClass new MyClass(); theMyClass-do_it(); delete theMyClass; } catch (const NXException e1) { UI::GetUI()-NXMessageBox()-Show(NXException, NXOpen::NXMessageBox::DialogTypeError, e1.Message()); } catch (const exception e2) { UI::GetUI()-NXMessageBox()-Show(Exception, NXOpen::NXMessageBox::DialogTypeError, e2.what()); } catch (...) { UI::GetUI()-NXMessageBox()-Show(Exception, NXOpen::NXMessageBox::DialogTypeError, Unknown Exception.); } UF_terminate();//出口函数 } //------------------------------------------------------------------------------ // Unload Handler //------------------------------------------------------------------------------ extern C DllExport int ufusr_ask_unload() { return (int)NXOpen::Session::LibraryUnloadOptionImmediately; }
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2439780.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!