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

C# NX二次开发:宏录制实战讲解(第一讲)

今天要讲的是关于NX软件录制宏操作的一些案例。

下面讲如何在NX软件中复制Part体的录制宏。

 NXOpen.Session theSession = NXOpen.Session.GetSession();
    NXOpen.Part workPart = theSession.Parts.Work;
    NXOpen.Part displayPart = theSession.Parts.Display;
    NXOpen.Matrix3x3 rotMatrix1 = new NXOpen.Matrix3x3();
    rotMatrix1.Xx = 0.89306013796526285;
    rotMatrix1.Xy = -0.44496658771914138;
    rotMatrix1.Xz = 0.066695770413509187;
    rotMatrix1.Yx = -0.39632123815418213;
    rotMatrix1.Yy = -0.70777276650451371;
    rotMatrix1.Yz = 0.58479670585809584;
    rotMatrix1.Zx = -0.21300954477535283;
    rotMatrix1.Zy = -0.5486915771251909;
    rotMatrix1.Zz = -0.80843335348466772;
    NXOpen.Point3d translation1 = new NXOpen.Point3d(-52.577957389047107, 41.350418114859622, 62.806893022449373);
    workPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix1, translation1, 0.68000460164672882);
    
    // ----------------------------------------------
    //   菜单:编辑(E)->复制(C)
    // ----------------------------------------------
    workPart.PmiManager.RestoreUnpastedObjects();
    
    // ----------------------------------------------
    //   菜单:编辑(E)->粘贴(P)
    // ----------------------------------------------
    NXOpen.Session.UndoMarkId markId1;
    markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "起点");
    
    NXOpen.NXObject[] features1 = new NXOpen.NXObject[1];
    NXOpen.Features.Brep brep1 = ((NXOpen.Features.Brep)workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(12)"));
    features1[0] = brep1;
    NXOpen.Features.CopyPasteBuilder copyPasteBuilder1;
    copyPasteBuilder1 = workPart.Features.CreateCopyPasteBuilder2(features1);
    
    copyPasteBuilder1.SetBuilderVersion((NXOpen.Features.CopyPasteBuilder.BuilderVersion)(7));
    
    NXOpen.Features.FeatureReferencesBuilder featureReferencesBuilder1;
    featureReferencesBuilder1 = copyPasteBuilder1.GetFeatureReferences();
    
    NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
    NXOpen.Vector3d normal1 = new NXOpen.Vector3d(0.0, 0.0, 1.0);
    NXOpen.Plane plane1;
    plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling);
    
    NXOpen.Unit unit1 = ((NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter"));
    NXOpen.Expression expression1;
    expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);
    
    NXOpen.Expression expression2;
    expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);
    
    featureReferencesBuilder1.AutomaticMatch(true);
    
    theSession.SetUndoMarkName(markId1, "粘贴特征 对话框");
    
    NXOpen.Features.MatchedReferenceBuilder[] matchedReferenceData1;
    matchedReferenceData1 = featureReferencesBuilder1.GetMatchedReferences();
    
    NXOpen.Session.UndoMarkId markId2;
    markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "粘贴特征");
    
    theSession.DeleteUndoMark(markId2, null);
    
    NXOpen.Session.UndoMarkId markId3;
    markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "粘贴特征");
    
    NXOpen.NXObject nXObject1;
    nXObject1 = copyPasteBuilder1.Commit();
    
    theSession.DeleteUndoMark(markId3, null);
    
    theSession.SetUndoMarkName(markId1, "粘贴特征");
    
    NXOpen.Features.Brep brep2 = ((NXOpen.Features.Brep)nXObject1);
    NXOpen.Expression[] expressions1;
    expressions1 = brep2.GetExpressions();
    
    copyPasteBuilder1.Destroy();

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

http://www.xdnf.cn/news/5109.html

相关文章:

  • Jetpack Compose 状态管理:为什么 `by viewModel.state` 能自动刷新界面?
  • C语言实现三子棋
  • java volatile关键字
  • LINUX CFS算法解析
  • YOLO目标检测算法
  • 麦角硫因:全能型护肤成分的技术突破与应用前景
  • 数据链路层服务
  • 基础RNN网络详解
  • 餐饮行业新风口:上门厨师服务系统的技术实现路径
  • 机器视觉的平板电脑屏幕组件覆膜应用
  • canoe的安装总结
  • requests库
  • 【笔记】BCEWithLogitsLoss
  • [Windows] 摄像头分身工具【CamSplitter】
  • upload文件上传
  • ES6新增Set、Map两种数据结构、WeakMap、WeakSet举例说明详细。(含DeepSeek讲解)
  • 【PINN】DeepXDE学习训练营(18)——operator-diff_rec_unaligned_pideeponet.py
  • 安全核查基线-1.LPD服务
  • 【软件设计师:体系结构】15.计算机体系结构概论
  • 将/root下的employee.json挪到/home/Downloads/
  • 让模型具备“道生一,一生二,二生三,三生万物”的现实实用主义能力
  • Stagehand:AI驱动的下一代浏览器自动化框架
  • 历史温度曲线能优化样本存储的条件还是确保样本处于稳定状态呢?
  • Linux系统入门第十一章 --Shell编程之函数与数组
  • CreArt 2.5.6 |无限AI图片生成工具,将文字描述转化为独特艺术作品,解锁高级版
  • FastChat部署大模型
  • 从量子计算到人工智能代理
  • PPT插入图像自带透明
  • 分布式处理架构
  • android动态调试