C#实现“抑制”NX特征及约束

        static void SuppressedAllConstraintAndFeature(bool bSuppress)
        {
            try
            {
                Session theSession = Session.GetSession();
                UFSession theUfSession = UFSession.GetUFSession();
                UFUi theUFUi = theUfSession.Ui;

                string path = @"D:	est_model\_model1.prt";
                NXOpen.Tag obj = NXOpen.Tag.Null;
                UFPart.LoadStatus LoadStatus;
                theUfSession.Part.Open(path, out obj, out LoadStatus);
                NXOpen.Part part = theSession.Parts.Display;
                
                Feature[] features = part.Features.ToArray();

                if (bSuppress)
                {
                    part.Features.SuppressFeatures(features);
                }
                else
                {
                    part.Features.UnsuppressFeatures(features);
                }

                ComponentAssembly componentAssembly = part.ComponentAssembly;
                ComponentPositioner componentPositioner = componentAssembly.Positioner;
                ConstraintCollection constraintCollection = componentPositioner.Constraints;
                foreach (Constraint c in constraintCollection)
                {
                    c.Suppressed = bSuppress;
                }

                part.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.True);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
作者:快雪
本文版权归作者所有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/kuaixue/p/14475632.html