• 装配焊接工序模型创建wave关系的函数


    //针对子节点为装配的工序模型,首先将子组件的几何实体几何链接到装配工序上
            public static void WavetheChildPart(string assem, string component)
            {
                try
                {
                    Part displaypart = Program.theSession.Parts.Display;
                    if (displaypart == null)
                    {
                        NXFun.MessageBox("请先打开part");
                        return;
                    }
                    //判断显示部件为转配节点 并加载子节点 获取子节点
                    List List_WaveObjects = new List();
                    Tag parttag = Program.theUfSession.Part.AskDisplayPart();
                    Tag roottag = Program.theUfSession.Assem.AskRootPartOcc(parttag);
                    if (roottag == Tag.Null)
                    {
                        MessageBox("The Part isnot an Assembly!");
                        return;
                    }
                    NXOpen.Tag[] childrenNum;
                    int chil = Program.theUfSession.Assem.AskAllPartOccChildren(roottag, out childrenNum);
                    string[] childrenName = new string[chil];
                    Part part1 = NXFun.Tag2NXObject(parttag);
                    //load all component 
                    string assemId = part1.GetStringAttribute("DB_PART_NO");
                    string assemVersion = part1.GetStringAttribute("DB_PART_REV");
                    string assembly = assemId + "/" + assemVersion;
                    LoadAllComponent(assembly);
                    //find the bodytype nxobject
                    for (int i = chil - 1; i >= 0; i--)
                    {
                        Tag childrentag = childrenNum[i];
                        NXOpen.Assemblies.Component part = NXFun.Tag2NXObject(childrentag);
                        //判断有无原型:componet 是否一定是一个实例
                        //Part ptt1 = (Part)part.OwningPart;//指装配总节点
                        //Part ptt2 = (Part)part.Prototype;
                        //if (part.IsOccurrence)
                        //{
                        //    ptt2 = (Part)part.Prototype;
                        //}
                        //else
                        //{ 
                        //}
                        Body[] bb = ((Part)part.Prototype).Bodies.ToArray();

                        foreach (Body bod in bb)
                        {
                            NXObject bod1 = part.FindOccurrence(bod);
                            if (bod1 != null)
                            {
                                List_WaveObjects.Add(bod1.Tag);
                            }
                        }

                    }
                    //remove the same object
                    List List_NewWaveObjects=RemoveTheSame(List_WaveObjects);
                    //将子节点所有几何体实体wave到父装配节点上
                    Part childPart = displaypart;
                    foreach (Tag objtag in List_NewWaveObjects)
                    {
                        NXObject obj = NXFun.Tag2NXObject(objtag);
                        NXFun.CreateWave3(objtag, childPart.Tag, false);

                    }
                    //hide all its childcomponent
                    BlankAllComponent();

                }
                catch (Exception err)
                {
                    MessageBox(err.ToString());
                }
            }
            //using the method recording the operation in Nx to create body wavelink
            public static void CreateWave3(Tag obj, Tag prt, bool update)
            {
                Session theSession = Session.GetSession();
                Part workPart = theSession.Parts.Work;

                NXOpen.Features.Feature nullFeatures_Feature = null;


                NXOpen.Features.WaveLinkBuilder waveLinkBuilder1;
                waveLinkBuilder1 = workPart.BaseFeatures.CreateWaveLinkBuilder(nullFeatures_Feature);

                NXOpen.Features.ExtractFaceBuilder extractFaceBuilder1;
                extractFaceBuilder1 = waveLinkBuilder1.ExtractFaceBuilder;

                extractFaceBuilder1.FaceOption = NXOpen.Features.ExtractFaceBuilder.FaceOptionType.FaceChain;

                waveLinkBuilder1.Type = NXOpen.Features.WaveLinkBuilder.Types.BodyLink;

                extractFaceBuilder1.FaceOption = NXOpen.Features.ExtractFaceBuilder.FaceOptionType.FaceChain;

                extractFaceBuilder1.AngleTolerance = 45.0;

                extractFaceBuilder1.ParentPart = NXOpen.Features.ExtractFaceBuilder.ParentPartType.OtherPart;

                extractFaceBuilder1.Associative = true;

                extractFaceBuilder1.FixAtCurrentTimestamp = update;//false;

                extractFaceBuilder1.HideOriginal = false;

                extractFaceBuilder1.InheritDisplayProperties = false;

                SelectObjectList selectObjectList1;
                selectObjectList1 = extractFaceBuilder1.BodyToExtract;

                //NXOpen.Assemblies.Component component1 = (NXOpen.Assemblies.Component)            workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT 1 1");
                //Body body1 = (Body)component1.FindObject("PROTO#.Bodies|BLOCK(3)");
                Body body2 = (Body)Tag2NXObject(obj);
                bool added1;
                added1 = selectObjectList1.Add(body2);

                NXObject nXObject1;
                nXObject1 = waveLinkBuilder1.Commit();

                waveLinkBuilder1.Destroy();
            }
            //判断是否为装配节点
            public static bool isAssem()
            {
                Part displaypart = Program.theSession.Parts.Display;
                if (displaypart == null)
                {
                    NXFun.MessageBox("请先打开part");
                    return false;
                }
                //判断显示部件为转配节点 并加载子节点 获取子节点
                List List_WaveObjects = new List();
                Tag parttag = Program.theUfSession.Part.AskDisplayPart();
                Tag roottag = Program.theUfSession.Assem.AskRootPartOcc(parttag);
                if (roottag == Tag.Null)
                {
                    return false;
                }
                return true;
            }

  • 相关阅读:
    MATLAB源码-第55期】matlab代码基于m序列的多用户跳频通信系统仿真,输出各节点波形图。
    uni-app 5小时快速入门 7 页面配置(上)
    软件测试之测试程序开发
    网络套接字2
    asp毕业设计——基于asp+access的学生论坛设计与实现(毕业论文+程序源码)——学生论坛
    gif动态图怎么制作?gif动态图在线制作一键搞定
    工程优化---一维搜索方法
    PySpark数据分析基础:pyspark.mllib.regression机器学习回归核心类详解(一)+代码详解
    三维模型几何坐标偏差修正(纠正)的常用方法分析
    Nvidia GPU 入门教程之 04 如何在 Ubunt 上安装 Anaconda Python 发行版
  • 原文地址:https://blog.csdn.net/zzjlhlcd/article/details/127649252