文章作者:里海
來源網站:https://blog.csdn.net/WangPaiFeiXingYuan
UF_CSYS_set_wcs
Defined in: uf_csys.h?
int UF_CSYS_set_wcs(tag_t csys_id )
overview 概述
Sets the work coordinate system to the prototype coordinate system whose
tag you specify and then updates the display. If an occurrence coordinate
system is specified, the work coordinate system will not be changed and
this function will return an error. Note that the current WCS can not
be deleted, so the tag that is passed in can not then be deleted using
UF_OBJ_delete_object.
將工作坐標系設置為您指定的標記的原型坐標系,然后更新顯示。如果指定了一個出現坐標系,工作坐標系將不會改變,這個函數將返回一個錯誤。請注意,當前的 WCS 無法刪除,因此傳入的標記不能使用 UF _ OBJ _ delete _ object 刪除。
UFUN例子
歡迎訂閱《里海NX二次開發3000例專欄》https://blog.csdn.net/wangpaifeixingyuan/category_8840986.html,點擊鏈接掃碼即可訂閱(持續更新中)。已經有幾百人訂閱,訂閱是永久的,無限期閱讀,如需幫助請私信。
parameters 參數
tag_t | csys_id | Input | Object identifier of the coordinate system to set the WCS to 坐標系的對象標識符,以便將 WCS 設置為 |
C++語言在UG二次開發中的應用及綜合分析
- C++ 是C語言的擴展,它既可以執行C語言的過程化程序設計,也可以進行以抽象數據類型為特點的基于對象的設計,以及面向對象的程序設計。C++ 在處理問題規模上具有很大的適應性。
- C++不僅具有計算機高效運行的實用性特征,并且致力于提升大規模程序的編程質量以及程序設計語言的問題描述能力。
在UG二次開發中,C++語言具有以下特點
- C++語言支持多種程序設計風格
- C++的許多特性以庫的形式存在,保證了語言的簡潔和開發運行的效率
- 與C語言相比,C++引入了面向對象的概念,使得UG二次開發的人機交互界面更加簡潔
- 通過借助UG自帶的2000多種API函數,結合高級語言C++以及編程軟件Visual Studio,可以對UG進行二次開發
- 需要注意的是,市場上的Visual Studio和UG版本眾多,并非所有版本都能兼容
程序設計過程通常包括以下步驟:
- 問題分析:對要解決的問題進行深入的分析,理解問題的具體需求和限制。
- 需求定義:明確程序的目標和功能,包括用戶需求、系統需求等。
- 設計:根據需求進行設計,包括算法設計、數據結構設計、界面設計等。
- 編碼:根據設計的結果,使用一種編程語言將程序代碼實現出來。
- 測試:通過各種測試方法來確保程序的正確性,包括單元測試、集成測試、系統測試等。
- 維護:對程序進行修改和完善,以解決可能出現的問題或滿足新的需求。
- 文檔編寫:編寫程序文檔,描述程序的功能、操作方法、注意事項等。
以下是一個創建體素特征(塊、柱、錐、球)的二次開發例子
#include <stdio.h>
#include <stdarg.h>
#include <uf_modl_primitives.h>
#include <uf_ui_ugopen.h>
#include <uf.h>
#include <uf_defs.h>
//封裝打印函數,用于將信息打印到信息窗口
//QQ3123197280
int ECHO(const char* szFormat, ...)
{char szMsg[5000] = "";va_list arg_ptr;va_start(arg_ptr, szFormat);vsprintf_s(szMsg, szFormat, arg_ptr);va_end(arg_ptr);UF_UI_open_listing_window();UF_UI_write_listing_window(szMsg);return 0;
}
extern DllExport void ufusr(char* param, int* returnCode, int rlen)
{UF_initialize();//創建塊UF_FEATURE_SIGN sign = UF_NULLSIGN;//塊起點相對于ABSdouble block_orig[3] = { 0.0,0.0,0.0 };//方向相對于WCSchar* block_len[3] = { "10", "30", "10" };tag_t blk_obj;//體特征UF_MODL_create_block1(sign, block_orig, block_len, &blk_obj);int iEdit = 0; char* size[3];UF_MODL_ask_block_parms(blk_obj, iEdit, size);ECHO("%s,%s,%s\n", size[0], size[1], size[2]);//輸出: p6=10,p7=30,p8=10//創建圓柱UF_FEATURE_SIGN sign1 = UF_NULLSIGN;double origin[3] = { 10.0,0.0,10.0 };char height[] = "20";char diam[] = "10";double direction[3] = { 0,0,1 };//方向tag_t cyl_obj_id;UF_MODL_create_cyl1(sign1, origin, height, diam, direction, &cyl_obj_id);int iEdit2 = 0; char* cDiameter;char* cHeight;UF_MODL_ask_cylinder_parms(cyl_obj_id, iEdit2, &cDiameter, &cHeight);ECHO("%s,%s\n", cDiameter, cHeight);//輸出:p9=10,p10=20UF_free(cDiameter);UF_free(cHeight);//創建圓錐UF_FEATURE_SIGN sign2 = UF_NULLSIGN;double origin2[3] = { 0.0,0.0,10.0 };char height2[] = "20";char* diam2[2] = { "10" ,"5" };double direction2[3] = { 0,0,1 };//方向tag_t cone_obj_id;UF_MODL_create_cone1(sign2, origin2, height2, diam2, direction2, &cone_obj_id);int iEdit3 = 0; char* cD1;char* cD2;char* cH;char* cAngle;UF_MODL_ask_cone_parms(cone_obj_id, iEdit3, &cD1, &cD2, &cH, &cAngle);ECHO("%s,%s,%s,%s\n", cD1, cD2, cH, cAngle);//輸出:p11=10,p12=5,p13=20,p14=7.1250163489018UF_free(cD1);UF_free(cD2);UF_free(cH);UF_free(cAngle);//創建球UF_FEATURE_SIGN sign3 = UF_NULLSIGN;double douCenter2[3] = { 0.0,0.0,30.0 };char cDiam[] = "8";tag_t sphere_obj_id;UF_MODL_create_sphere1(sign3, douCenter2, cDiam, &sphere_obj_id);int iEdit4 = 0; char* cDiam_parm;UF_MODL_ask_sphere_parms(sphere_obj_id, iEdit4, &cDiam_parm);ECHO("%s\n", cDiam_parm);//輸出:p15=8UF_free(cDiam_parm);UF_terminate();
}
extern int ufusr_ask_unload(void)
{return (UF_UNLOAD_IMMEDIATELY);
}
效果: