标签:include void 起始 lw 角度 ARC UI 圆弧 UF
//CESHI_ARC // Mandatory UF Includes #include "C:\\all_uf.h" #include <uf.h> #include <uf_modl.h> #include <uf_disp.h> #include<vector> // Internal Includes #include <NXOpen/ListingWindow.hxx> #include <NXOpen/NXMessageBox.hxx> #include <NXOpen/UI.hxx> // Internal+External 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> #include <uf_defs.h> #include <NXOpen/NXException.hxx> #include <NXOpen/ModelingView.hxx> #include <NXOpen/ModelingViewCollection.hxx> #include <NXOpen/Part.hxx> #include <NXOpen/PartCollection.hxx> #include <NXOpen/Session.hxx> #include <NXOpen/UI.hxx> #include <NXOpen/selection.hxx> #include <NXOpen/Features_Feature.hxx> #include <NXOpen/Part.hxx> #include <NXOpen/PartCollection.hxx> #include <NXOpen/ListingWindow.hxx> #include <NXOpen/NXObject.hxx> #include <NXOpen/NXObjectManager.hxx> // Std C++ Includes #include <iostream> #include <sstream> 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 C_ARC { // class members public: static Session *theSession; static UI *theUI; C_ARC(); ~C_ARC(); void do_it(); void print(const NXString &); void print(const string &); void print(const char*); private: Part *workPart, *displayPart; NXMessageBox *mb; ListingWindow *lw; }; //------------------------------------------------------------------------------ // Initialize static variables //------------------------------------------------------------------------------ Session *(C_ARC::theSession) = NULL; UI *(C_ARC::theUI) = NULL; //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ C_ARC::C_ARC() { // Initialize the NX Open C++ API environment C_ARC::theSession = NXOpen::Session::GetSession(); C_ARC::theUI = UI::GetUI(); mb = theUI->NXMessageBox(); lw = theSession->ListingWindow(); workPart = theSession->Parts()->Work(); displayPart = theSession->Parts()->Display(); } //------------------------------------------------------------------------------ // Destructor //------------------------------------------------------------------------------ C_ARC::~C_ARC() { } //------------------------------------------------------------------------------ // Print string to listing window or stdout //------------------------------------------------------------------------------ void C_ARC::print(const NXString &msg) { if(! lw->IsOpen() ) lw->Open(); lw->WriteLine(msg); } void C_ARC::print(const string &msg) { if(! lw->IsOpen() ) lw->Open(); lw->WriteLine(msg); } void C_ARC::print(const char * msg) { if(! lw->IsOpen() ) lw->Open(); lw->WriteLine(msg); } //预选高亮 static int select_filter_proc_fn(tag_t object, int type[3], void* user_data, UF_UI_selection_p_t select) { if (object == NULL) { return UF_UI_SEL_REJECT; } else { return UF_UI_SEL_ACCEPT; } } static int init_proc(UF_UI_selection_p_t select, void* user_data) { int num_triples = 1;//可选类型的数量 UF_UI_mask_t mask_triples[] = { UF_circle_type, UF_circle_open_subtype };//可选对象类型 UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples); if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0) { return UF_UI_SEL_SUCCESS; } else { return UF_UI_SEL_FAILURE; } } //------------------------------------------------------------------------------ // Do something //------------------------------------------------------------------------------ void C_ARC::do_it() { // TODO: add your code here UF_initialize(); //单对象选择对话框 char sCue[] = "单对象选择对话框"; char sTitle[] = "单对象选择对话框"; int iScope = UF_UI_SEL_SCOPE_NO_CHANGE; int iResponse; tag_t tObject; tag_t tView; double adCursor[3]; UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &tObject, adCursor, &tView); UF_CURVE_arc_t Obj_data; UF_CURVE_ask_arc_data(tObject, &Obj_data); char aa[256]; if (tObject > 0) { double Sp = Obj_data.start_angle/PI*180.0; double Ep = Obj_data.end_angle /PI*180.0; sprintf(aa, "%f\n%f", Sp,Ep); uc1601(aa, 1); } UF_DISP_set_highlight(tObject,0); UF_terminate(); } //------------------------------------------------------------------------------ // Entry point(s) for unmanaged internal NXOpen C/C++ programs //------------------------------------------------------------------------------ // Explicit Execution extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen ) { try { // Create NXOpen C++ class instance C_ARC *theC_ARC; theC_ARC = new C_ARC(); theC_ARC->do_it(); delete theC_ARC; } 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."); } } //------------------------------------------------------------------------------ // Unload Handler //------------------------------------------------------------------------------ extern "C" DllExport int ufusr_ask_unload() { return (int)NXOpen::Session::LibraryUnloadOptionImmediately; }
部分代码转自https://www.cnblogs.com/nxopen2018/p/10957188.html卢尚宇
标签:include,void,起始,lw,角度,ARC,UI,圆弧,UF 来源: https://www.cnblogs.com/liuxiaoqing1/p/12209071.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。