UG/NX二开Siemens官方实例解析 4.6 EX_Facet(切面模型分离)

前言

        本系列文章主要讲解NXOpen UF API(简称ufun函数)的使用,之前看教学视频大都建议用ufun进行开发,这里西门子官方还专门给了一套系列文章来讲,说明官方也是特别推崇ufun。

        本人从事二开也有一段时间了,我的二开启蒙师父就特别喜欢用NXOpen API,用他的话来说“年少不知nxopen好,错把ufun当成宝”,其实就我个人而言,还是喜欢NXOPEN+ufun联合开发。


一、小节概要

本实例完成了切面模型与实体分离的实现,具体知识点如下:

1、创建块 theUfSession.Modl.CreateBlock1

2、生成切面模型 theUfSession.Facet.FacetSolid

3、倒斜角 theUfSession.Modl.CreateBlend

4、切面模型与关联实体分离 theUfSession.Facet.DisassocFromSolid

二、需求分析

1、效果图

 

2、需求分解

1、生成块

2、生成切面模型

3、处理切面模型

4、分离切面模型

三、程序分析

1、源码所在目录

UGOPEN\SampleNXOpenApplications\.NET\NXOpenExamples\EX_Facet

2、主要功能分析 

1、生成块

Tag block_feature_tag;
string[] edge_lengths = { "10", "30", "40" };
corner_point[0] = 0.0;
corner_point[1] = 0.0;
corner_point[2] = 0.0;
theUfSession.Modl.CreateBlock1(FeatureSigns.Nullsign, corner_point, edge_lengths, out block_feature_tag );

2、 生成切面模型

Tag faceted_model;
UFInitParams(ref faceting_params);
theUfSession.Facet.AskDefaultParameters(out faceting_params) ;
theUfSession.Facet.FacetSolid(block_tag, ref faceting_params, out faceted_model );

3、 处理切面模型,倒斜角

theUfSession.Facet.AskSolidOfModel(faceted_model, out tag_of_solid );
theUfSession.Facet.AskModelsOfSolid(block_tag,out n_facet_models, out facet_models);
theUfSession.Modl.AskBodyEdges(block_tag, out edge_list);
theUfSession.Modl.CreateBlend("2.0", edge_list,0, 0, 0, 0.0,out blend_feature);

4、 分离切面模型

theUfSession.Modl.Update();
theUfSession.Facet.IsModelUpToDate(faceted_model,out up_to_date);
theUfSession.Facet.AskModelParameters(faceted_model, out faceting_params);
faceting_params.max_facet_edges = 4;
theUfSession.Facet.UpdateModel(faceted_model, ref faceting_params);
theUfSession.Facet.IsModelUpToDate(faceted_model, out up_to_date);
theUfSession.Facet.DisassocFromSolid(faceted_model);
new_faceted_model = faceted_model;

总结:

        这里做切面模型分离,暂时还不知道有什么用,后面有用上的时候,再补充完整~

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
如果你想在 UG NX CAD 软件中使用这个函数,可以按照以下步骤: 1. 在你的代码中包含 UG NX CAD 软件的头文件,例如:`#include <uf.h>` 2. 声明需要使用的变量,例如:`tag_t model; int num_vertices, new_facet_id, status; double vertices[3][3], normals[3][3]; int adjacent_facet_ids[3];` 3. 给变量赋值,例如:给vertices数组赋值(此处为一个三角形面片): ``` vertices[0][0] = 0.0; vertices[0][1] = 0.0; vertices[0][2] = 0.0; vertices[1][0] = 1.0; vertices[1][1] = 0.0; vertices[1][2] = 0.0; vertices[2][0] = 0.0; vertices[2][1] = 1.0; vertices[2][2] = 0.0; ``` 给normals数组赋值(此处为三个顶点的法向量): ``` normals[0][0] = 0.0; normals[0][1] = 0.0; normals[0][2] = 1.0; normals[1][0] = 0.0; normals[1][1] = 0.0; normals[1][2] = 1.0; normals[2][0] = 0.0; normals[2][1] = 0.0; normals[2][2] = 1.0; ``` 给adjacent_facet_ids数组赋值(此处为三个顶点相邻的面片ID都为0): ``` adjacent_facet_ids[0] = 0; adjacent_facet_ids[1] = 0; adjacent_facet_ids[2] = 0; ``` 4. 调用该函数将面片添加到模型中,例如:`status = UF_FACET_add_facet_to_model(model, num_vertices, vertices, normals, adjacent_facet_ids, &new_facet_id);` 5. 检查函数调用的返回值status,如果为0,则表示函数调用成功,否则表示失败。 6. 如果函数调用成功,则可以使用获取到的新面片ID进行后续操作,例如输出新面片的ID,例如:`printf("The ID of the new facet is %d\n", new_facet_id);`

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MarcoPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值