当前位置: 首页 > news >正文

C# NX二次开发:模型导入和向量及点位的使用

大家好,今天讲NX二次开发中的导入模型的相关操作。

首先介绍一下导入模型要使用的UFUN函数:

UF_PART_import (view source)

const char *file_nameInputFile specification of NX disk file to import.
UF_import_part_modes_t *modesInputInputs are specified in the `modes' structure.
doubledest_csys [ 6 ]InputDestination Coordinate System. dest_csys[0..2] is an
X-direction vector, and dest_csys[3..5] is a y direction
vector. These are used as input to UF_MTX3_initialize
to create the full coordinate system matrix.
doubledest_point [ 3 ]InputDestination point of imported part
doublescaleInputThe scale size for the imported part.
tag_t *groupOutputIf grouping is desired, the group is returned,
otherwise it is a NULL_TAG

上面是官方的UFUN函数解释。

下面使用一个例子加深一下大家的理解。

 public Tag ImportPart(double[] xaix,double[] yaix,double[] point)
    {
        string path = @"C:\例子.prt";
        ImportPartModes importPartModes = new ImportPartModes();
        importPartModes.layer_mode = 0;
        importPartModes.group_mode = 0;
        importPartModes.csys_mode = 0;
        importPartModes.plist_mode = 0;
        importPartModes.view_mode = 0;
        importPartModes.cam_mode = false;
        importPartModes.use_search_dirs = false;
        double[] dest_csys = new double[] { xaix[0], xaix[1], xaix[2], yaix[0], yaix[1], yaix[2] };
        var dest_point = new double[] { point[0], point[1], point[2] };
        Tag group = new Tag();
        theUfSession.Part.Import(path, ref importPartModes, dest_csys, dest_point, 1.0, out group);
        theUfSession.Modl.Update();
        return group;
    }

这个例子可以看出,导入的这个方法,第一个参数为导入模型的路径,第二个参数为ImportPartModes,这个实体类建议按照我上面的用法进行使用就行,第三个参数为x轴和y轴的三个分向量点位坐标为double类型,第四个参数为原点也是为double,第六个参数为比例,第七个参数为返回值,如果你没有进行分组,那么这个返回值就是null。

下面介绍一下再NX中向量是如何进行使用的:

                Point3d point3D = point0.Point;

                Vector3d vector3DX = vector05.Vector;
                Vector3d vector3DY = vector06.Vector;
                Vector3d vector3DZ = vector08.Vector;
                double[] point = { point3D.X, point3D.Y, point3D.Z };
                double[] xaix = { vector3DX.X, vector3DX.Y, vector3DX.Z };
                double[] yaix = { vector3DY.X, vector3DY.Y, vector3DY.Z };

可以看到上面我将三个向量进行了拆解,里面还包括了一个点位的拆解。

今天要介绍的就是这么多,我们下篇文章再见。

相关文章:

  • 连锁企业管理系统 解决了哪些问题
  • ##Hive安装-初始化元数据报错 *** schemaTool failed ***
  • IXTUR气控永磁铁:以高精度气控和稳定磁场,为机器人应用提供稳定抓取力
  • C++复试笔记(二)
  • 微服务新手入门
  • ROS实践(四)机器人建图(gmapping)
  • 一维下料之 *贪心算法* —— CAD c#二次开发
  • Comfyui 与 SDwebui
  • 修复Electron项目Insecure Content-Security-Policy(内容安全策略CSP)警告的问题
  • 【ELK】ElasticSearch 集群常用管理API操作
  • 1.1.系统工程与信息系统基础简介
  • mysql安装过程
  • 蓝桥杯备考:数据结构vector篇之寄包柜
  • java中小型公司面试预习资料(四):微服务架构
  • ubuntu22.04 关于挂在设备为nfts文件格式无法创建软连接的问题
  • 【银行测试】银行项目,信贷/贷款业务测试+常问面试(二)
  • jira操作笔记
  • HTML5(Web前端开发笔记第一期)
  • AGI大模型(1):大模型简介
  • Manus 一码难求,MetaGPT、OpenManus、Camel AI 会是替代方案吗?
  • 教育部、国家发改委联合启动实施教师教育能力提升工程
  • 澎湃研究所“营商环境研究伙伴计划”启动
  • 太原一高中生指出博物馆多件藏品标识不当,馆方已邀请他和专家共同探讨
  • 默茨当选德国总理
  • 伯克希尔董事会投票决定:阿贝尔明年1月1日起出任CEO,巴菲特继续担任董事长
  • 让党的理论“飞入寻常百姓家”,他如何做到有新意?