UF_MODL_create_extruded
时间: 2023-08-07 09:04:07 浏览: 65
`UF_MODL_create_extruded` 是 UG NX 中用于创建拉伸特征的函数。通过该函数,可以从一个或多个截面轮廓创建一个拉伸体。拉伸特征是在一个方向上沿着一个曲线或一个路径进行延伸形成的。
函数的语法为:
```
int UF_MODL_create_extruded (
int num_sections,
tag_t *section_tags,
double *section_parameters,
double *direction,
logical limit_flag,
double limit_distance,
tag_t *feature_tag
);
```
其中,参数的含义如下:
- `num_sections`:截面轮廓数目
- `section_tags`:截面轮廓的标签数组
- `section_parameters`:截面参数数组
- `direction`:拉伸的方向
- `limit_flag`:是否限制拉伸距离的标志
- `limit_distance`:拉伸的限制距离
- `feature_tag`:创建的拉伸特征的标签
使用该函数可以创建一个拉伸特征,根据提供的截面轮廓和参数进行拉伸操作。
相关问题
extern UFUNEXPORT int UF_MODL_ask_face_data( tag_t face ,/* <I> Face obj_id / int * type ,/ <O> Face type is NX surface type code 16 = cylinder 17 = cone 18 = sphere 19 = revolved (toroidal) 20 = extruded 22 = bounded plane 23 = fillet (blend) 43 = b-surface 65 = offset surface 66 = foreign surface / double point[] ,/ <O,len:3> Point information is returned according to the value of type as follows. Plane = Position in plane Cylinder= Position on axis Cone = Position on axis Sphere = Center position Torus = Center position Revolved = Position on axis / double dir[] ,/ <O,len:3> Direction information is returned according to the value of type as follows. Plane = Normal direction Cylinder= Axis direction Cone = Axis direction Torus = Axis direction Revolved = Axis direction / double box[] ,/ <O,len:6> Face boundary. The coordinates of the opposite corners of a rectangular box with sides parallel to X, Y, and Z axes (Absolute Coordinate System) are returned. The box contains the specified face and is usually close to the minimum possible size, but this is not guaranteed. box[0] = Xmin box[1] = Ymin box[2] = Zmin box[3] = Xmax box[4] = Ymax box[5] = Zmax / double * radius ,/ <O> Face major radius: For a cone, the radius is taken at the point[3] position on the axis. For a torus, the radius is taken at the major axis. / double * rad_data ,/ <O> Face minor radius: only a torus or cone has rad_data as a minor radius. For a cone, rad_data is the half angle in radians. For a torus, rad_data is taken at the minor axis. / int * norm_dir / <O> Face normal direction: +1 if the face normal is in the same direction as the surface normal (cross product of the U- and V-derivative vectors), -1 if reversed. */ ); 详解
`UF_MODL_ask_face_data` 函数是 UG/Open C API 中的一个函数,用于查询面(face)的数据。以下是该函数的详细解释:
函数原型:
```c
extern UFUNEXPORT int UF_MODL_ask_face_data(
tag_t face, /* <I> 面对象的 ID */
int *type, /* <O> 面的类型,NX 表面类型代码 16 = 圆柱体,17 = 圆锥体,18 = 球体,19 = 旋转体(环形),20 = 挤出体,22 = 平面,23 = 圆弧,43 = B 曲面,65 = 偏移曲面,66 = 外部曲面 */
double point[], /* <O,len:3> 根据类型返回点信息,具体如下:平面=平面上的位置,圆柱体=轴上的位置,圆锥体=轴上的位置,球体=中心位置,旋转体=轴上的位置 */
double dir[], /* <O,len:3> 根据类型返回方向信息,具体如下:平面=法线方向,圆柱体=轴向,圆锥体=轴向,旋转体=轴向 */
double box[], /* <O,len:6> 面边界,返回一个矩形盒子的对角线上的两个点的坐标(参考绝对坐标系),盒子包含了指定的面并且通常是最小可能的,但是不能保证。 */
double *radius, /* <O> 面的主要半径:对于圆锥体,半径是在轴上的点[3]处取的。对于环体,半径是在主轴上取的。 */
double *rad_data, /* <O> 面的次要半径:只有环体或圆锥体具有 rad_data 作为次要半径。对于圆锥体,rad_data 是半角的一半,对于环体,rad_data 是在副轴上取的。 */
int *norm_dir /* <O> 面的法线方向:+1 表示面法线与曲面法线(U- 和 V- 导数向量的叉积)相同,-1 表示相反。 */
);
```
参数说明:
- `face`:要查询的面对象的 ID。
- `type`:返回该面的类型,NX 表面类型代码。
- `point[]`:根据类型返回点信息。具体如下:
- 平面:平面上的位置。
- 圆柱体:轴上的位置。
- 圆锥体:轴上的位置。
- 球体:中心位置。
- 旋转体:轴上的位置。
- `dir[]`:根据类型返回方向信息。具体如下:
- 平面:法线方向。
- 圆柱体:轴向。
- 圆锥体:轴向。
- 旋转体:轴向。
- `box[]`:面边界,返回一个矩形盒子的对角线上的两个点的坐标(参考绝对坐标系),盒子包含了指定的面并且通常是最小可能的,但是不能保证。
- `radius`:返回面的主要半径。对于圆锥体,半径是在轴上的点[3]处取的。对于环体,半径是在主轴上取的。
- `rad_data`:返回面的次要半径。只有环体或圆锥体具有 rad_data 作为次要半径。对于圆锥体,rad_data 是半角的一半,对于环体,rad_data 是在副轴上取的。
- `norm_dir`:返回面的法线方向。+1 表示面法线与曲面法线(U- 和 V- 导数向量的叉积)相同,-1 表示相反。
函数返回值:
- `0` 表示成功。
- 非 `0` 值表示失败。
使用示例:
```c
#include <uf_modl.h>
#include <stdio.h>
int main()
{
tag_t face;
int type;
double point[3], dir[3], box[6], radius, rad_data;
int norm_dir;
// 获取一个面的 ID
// ...
int ret = UF_MODL_ask_face_data(face, &type, point, dir, box, &radius, &rad_data, &norm_dir);
if (ret != 0)
{
printf("查询面数据失败!\n");
return 1;
}
printf("面类型:%d\n", type);
printf("点坐标:(%lf, %lf, %lf)\n", point[0], point[1], point[2]);
printf("方向向量:(%lf, %lf, %lf)\n", dir[0], dir[1], dir[2]);
printf("盒子坐标:(%lf, %lf, %lf), (%lf, %lf, %lf)\n", box[0], box[1], box[2], box[3], box[4], box[5]);
printf("主要半径:%lf\n", radius);
printf("次要半径:%lf\n", rad_data);
printf("法线方向:%d\n", norm_dir);
return 0;
}
```
该示例中,我们首先获取了一个面对象的 ID `face`,然后调用 `UF_MODL_ask_face_data` 函数查询该面的数据。函数返回成功后,我们打印出面的类型、点坐标、方向向量、盒子坐标、主要半径、次要半径和法线方向。
NXOpenC++ 创建方块
以下是使用NXOpen C++ API创建方块的示例代码:
```cpp
#include <uf_part.h>
#include <uf_sket.h>
#include <uf_modl.h>
// 创建方块
void createBlock()
{
tag_t partTag = UF_PART_ask_display_part();
tag_t sketchTag = 0;
// 创建草绘
UF_SKET_create(&sketchTag);
double origin[3] = { 0.0, 0.0, 0.0 };
double xaxis[3] = { 1.0, 0.0, 0.0 };
double yaxis[3] = { 0.0, 1.0, 0.0 };
UF_SKET_create_origin(sketchTag, origin, xaxis, yaxis);
// 创建矩形
double corner1[2] = { 0.0, 0.0 };
double corner2[2] = { 10.0, 20.0 };
UF_SKET_create_rectangle(sketchTag, corner1, corner2);
// 创建拉伸特征
tag_t featureTag = 0;
UF_MODL_create_extruded(sketchTag, 30.0, &featureTag);
UF_PART_update(partTag, true);
}
```
上述代码使用了NXOpen C++ API中的uf_part.h、uf_sket.h和uf_modl.h头文件中的函数,实现了在当前显示部件中创建一个10x20x30的方块的功能。具体实现过程是,先创建一个草绘对象,然后在草绘对象中创建一个矩形,最后使用矩形拉伸的方式创建一个实体对象。需要注意的是,创建实体对象后需要调用UF_PART_update函数更新显示部件。
需要注意的是,NXOpen C++ API的使用需要一定的编程基础和相关知识,建议您在学习API之前先掌握C++编程基础。同时,为了遵守法律法规和保护他人知识产权,请勿将该代码用于商业用途或其他违法行为。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![.pdf](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/octet-stream](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![jpg](https://img-home.csdnimg.cn/images/20210720090814.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)