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

C# NX二次开发:获取模型中所有的草图并获取草图中的对象

大家好,今天接着讲NX二次开发获取草图相关。

获取草图的方法是从workPart中获取,如下面的例子所示:

  List<Tag> tags = new List<Tag>();
                SketchCollection sketchCollection = workPart.Sketches;
                Sketch[] sketches = sketchCollection.ToArray();
                for (int i = 0; i < sketches.Length; i++)
                {
                    string name = sketches[i].Name;
                    if (i == sketches.Length - 1)
                    {
                        group = sketches[i].Tag;
                        Feature feature = sketches[i].Feature;
                        NXObject[] nXObjects = feature.GetEntities();
                        //TaggedObject[] GetSelectedObjects1=
                        for (int j = 0; j < nXObjects.Length; j++)
                        {
                            if(nXObjects[j].ToString().Contains("Arc")|| nXObjects[j].ToString().Contains("Line"))
                            {
                                tags.Add(nXObjects[j].Tag);
                            }                            
                        }
                        //theUI.NXMessageBox.Show("提示", NXMessageBox.DialogType.Information, name);
                    }
                }

在上面的例子中获取了所有的草图,并且在获取到最后一个草图的时候,取出了草图中的Arc对象和Line对象的Tag值。

当然我们的类型都是从NXObject这个基类中进行获取的,下面是NXObject包含的内容:

  public enum AttributeType
        {
            Invalid = 0,
            Null = 1,
            Boolean = 2,
            Integer = 3,
            Real = 4,
            String = 5,
            Time = 6,
            Reference = 7,
            Any = 100
        }
        public enum DateAndTimeFormat
        {
            Numeric = 0,
            Textual = 1
        }

        public struct ComputationalTime
        {
            public int Day;
            public int Minute;

            public ComputationalTime(int Day, int Minute);

            public override string ToString();
        }
        public struct AttributeInformation
        {
            public AttributeType Type;
            public Unit Unit;
            public int ArrayElementIndex;
            public bool NotSaved;
            public bool PdmBased;
            public bool Array;
            public bool Unset;
            public bool Required;
            public bool OwnedBySystem;
            public bool Locked;
            public bool IsOverride;
            public bool Inherited;
            public string ReferenceValue;
            public ComputationalTime CompTimeValue;
            public string TimeValue;
            public string StringValue;
            public double RealValue;
            public int IntegerValue;
            public bool BooleanValue;
            public string TitleAlias;
            public string Title;
            public string Category;
            public Expression Expression;

            public override string ToString();
        }

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

散会


http://www.kler.cn/a/584411.html

相关文章:

  • 基于SpringBoot + Vue 的校园论坛系统
  • K8S学习之基础二十六:k8s的StatefulSet控制器
  • 在 Ubuntu 上安装和配置 Docker 的完整指南
  • 网络爬虫-1:发送请求+维持会话+代理设置/超时设置
  • 高德爬取瓦片和vue2使用
  • Sglang部署大模型常用参数详解
  • 【Oracle】19c数据库控制文件多路径配置
  • 使用阿里云操作系统控制台巧解调度抖动
  • Python----数据可视化(pyecharts二:绘图一:条形图,直方图,折线图,散点图,箱图,饼图,热力图)
  • 若依RuoYi-Cloud-Plus微服务版(完整版)前后端部署
  • Spring MVC中的Controller加载控制与Bean加载控制详解
  • cu118 安装vllm 极简教程 踩坑笔记
  • 信奥赛CSP-J复赛集训(模拟算法专题)(10):P2356 弹珠游戏
  • 本地算力部署大模型详细流程(一)
  • 虚幻引擎入门
  • 玩转云服务器——阿里云操作系统控制台体验测评
  • 游戏引擎学习第154天
  • Hutool RedisDS:Java开发中的Redis极简集成与高阶应用
  • 云原生性能测试全解析:如何构建高效稳定的现代应用?
  • 一文了解JVM的垃圾回收