1. 程式人生 > 實用技巧 >NX二次開發-射線焦點

NX二次開發-射線焦點

函式:UF_MODL_trace_a_ray()

函式說明:打射線,找交點。

用法:

 1 #include "Text.h"
 2 
 3 #include <stdio.h>
 4 #include <uf.h>
 5 #include <uf_part.h>
 6 #include <uf_defs.h>
 7 #include <uf_modl.h>
 8 void ufusr(char *param, int *retcode, int param_len)
 9 {
10     UF_initialize();
11     tag_t tagBody[2
] = { 45071,138371}; 12 double douPoint[3] = { 0.0,0.0,0.0 }; 13 double douRaydir[3] = { 0.0,1.0,0.5 }; 14 double transform[16] = { 1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0 }; 15 int hits_found; 16 UF_MODL_ray_hit_point_info_p_t hit_list; 17 UF_MODL_trace_a_ray(2, tagBody, douPoint, douRaydir, transform, 0
, &hits_found, &hit_list); 18 for (int i = 0; i < hits_found; i++) 19 { 20 tag_t tagPoint; 21 UF_CURVE_create_point(hit_list[i].hit_point, &tagPoint); 22 } 23 UF_terminate(); 24 } 25 26 int ufusr_ask_unload(void) 27 { 28 return (UF_UNLOAD_IMMEDIATELY);
29 }

效果: