赞
踩
文章作者:里海
来源网站:https://blog.csdn.net/WangPaiFeiXingYuan
Defined in: uf_assem.h
int UF_ASSEM_ask_component_data(tag_t component, char part_name [ MAX_FSPEC_BUFSIZE ] , char refset_name [ UF_OBJ_NAME_BUFSIZE ] , char instance_name [ UF_CFI_MAX_FILE_NAME_BUFSIZE ] , double origin [ 3 ] , double csys_matrix [ 9 ] , double transform [ 4 ] [ 4 ] )
Returns data about an instance or a part occurrence. The instance_name
output is always the name of the instance, even when a part occurrence is
passed to the function. Note that the names of the part occurrence and its
corresponding instance can be different. The refset_name can be different
between a part occurrence and its instance. The full 9 elements of the
csys_matrix are returned and may contain a reflection. The full transformation
matrix is also returned. The transformation matrix is the 4x4 matrix that
combines the origin and CSYS-matrix into a single matrix.
The format of the 4x4 transform is that the elements:
transform[0][0], transform[0][1], transform[0][2]
transform[1][0], transform[1][1], transform[1][2]
transform[2][0], transform[2][1], transform[2][2]
form a 3x3 orthnormal rotation matrix, the elements :
transform[0][3]
transform[1][3]
transform[2][3]
represent a (X, Y, Z) translation in the units of the part containing the
component, element
transform[3][3]
is always set to 1.0, and the remaining elements are always set to 0.0.
CAUTION: If the reference set of the component you are asking for
data on is set to “Entire Part”, the string returned by
UF_ASSEM_ask_component_data for refset_name (third argument)
is “None”.
返回有关实例或部件事件的数据。Instance _ name 输出始终是实例的名称,即使在将部分匹配项传递给函数时也是如此。请注意,部件出现的名称及其对应的实例可能不同。Refset _ name 在部件出现和它的实例之间可以是不同的。返回 csys _ Matrix 的完整9个元素,它们可能包含一个反射。完整的变换矩阵也会返回。变换矩阵是4 × 4矩阵,它将原点和 CSYS 矩阵组合成一个单独的矩阵。4x4转换的格式是: 转换[0][0]、转换[0][1]、转换[0][2]转换[1][0]、转换[1][1],变换[1][2]变换[2][0]变换[2][1]变换[2][2]形成一个3x3的正交旋转矩阵,元素: 转换[0][3]转换[1][3]转换[2][3]表示包含组件的零件的单位的(X,Y,Z)转换,元素转换[3][3]总是设置为1.0,其余元素总是设置为0.0。注意: 如果您请求数据的组件的引用集被设置为“整个部分”,那么由 UF _ ASSEM _ ask _ Component _ data 为 refset _ name (第三个参数)返回的字符串是“无”。
欢迎订阅《里海NX二次开发3000例专栏》https://blog.csdn.net/wangpaifeixingyuan/category_8840986.html,点击链接扫码即可订阅(持续更新中)。已经有几百人订阅,订阅是永久的,无限期阅读,如需帮助请私信。
tag_t | component | Input | Tag of instance or part occurrence 实例或部分出现的标记 |
char | part_name [ MAX_FSPEC_BUFSIZE ] | Output | Name of part 部分名称 |
char | refset_name [ UF_OBJ_NAME_BUFSIZE ] | Output | Name of the reference set in use 正在使用的引用集的名称 |
char | instance_name [ UF_CFI_MAX_FILE_NAME_BUFSIZE ] | Output | name of instance 实例名称 |
double | origin [ 3 ] | Output | Position of component 元件位置 |
double | csys_matrix [ 9 ] | Output | Coordinate System Matrix 坐标系矩阵 |
double | transform [ 4 ] [ 4 ] | Output | Transformation Matrix 变换矩阵 |
#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; //块起点相对于ABS double block_orig[3] = { 0.0,0.0,0.0 }; //方向相对于WCS char* 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=20 UF_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.1250163489018 UF_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=8 UF_free(cDiam_parm); UF_terminate(); } extern int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }
效果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。