public List <NXOpen.Features.TrimBody2> CreateBuilder()
        {
            List <NXOpen.Features.TrimBody2> trims = new List <NXOpen.Features.TrimBody2>();

            foreach (Face face in faces)
            {
                bool isok;
                NXOpen.Features.TrimBody2 trim = null;
                try
                {
                    trim = TrimBodyUtils.CreateTrimBodyFeature(face, true, out isok, body);
                }
                catch (NXException ex)
                {
                    ClassItem.WriteLogFile(ex.Message);
                    continue;
                }
                if (trim != null)
                {
                    trims.Add(trim);
                    Body temp = trim.GetBodies()[0];
                    if (isok)
                    {
                        body = temp;
                    }
                }
            }
            return(trims);
        }
Esempio n. 2
0
        /// <summary>
        ///  创建修剪特征
        /// </summary>
        /// <param name="planeFace"></param>
        /// <param name="isFlip"></param>
        /// <param name="isok"></param>
        /// <param name="bodys"></param>
        /// <returns></returns>
        public static NXOpen.Features.TrimBody2 CreateTrimBodyFeature(Face planeFace, bool isFlip, out bool isok, params Body[] bodys)
        {
            Part workPart = theSession.Parts.Work;

            NXOpen.Features.TrimBody2        nullNXOpen_Features_TrimBody2 = null;
            NXOpen.Features.TrimBody2Builder trimBody2Builder1             = workPart.Features.CreateTrimBody2Builder(nullNXOpen_Features_TrimBody2);
            List <TaggedObject> tgs = new List <TaggedObject>();

            foreach (Body body in bodys)
            {
                tgs.Add(body);
            }
            SelectionRuleFactory fac = new SelectionRuleFactory(tgs);

            NXOpen.Plane plane1 = null;
            try
            {
                plane1 = PlaneUtils.CreatePlaneOfFace(planeFace, isFlip);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("Basic.TrimBody:CreateTrimBodyFeature:" + ex.Message);
                throw ex;
            }
            trimBody2Builder1.BooleanTool.FacePlaneTool.ToolPlane = plane1;
            trimBody2Builder1.BooleanTool.ToolOption = NXOpen.GeometricUtilities.BooleanToolBuilder.BooleanToolType.NewPlane;
            NXOpen.ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();
            scCollector1.ReplaceRules(fac.CreateSelectionRule().ToArray(), false);
            trimBody2Builder1.TargetBodyCollector = scCollector1;

            try
            {
                isok = true;
                return(trimBody2Builder1.CommitFeature() as NXOpen.Features.TrimBody2);
            }
            catch (Exception ex)
            {
                LogMgr.WriteLog("Basic.TrimBody:CreateTrimBodyFeature:" + ex.Message);
                throw ex;
            }
            finally
            {
                trimBody2Builder1.Destroy();
            }
        }
Esempio n. 3
0
        public List <NXOpen.Features.TrimBody2> CreateBuilder()
        {
            List <NXOpen.Features.TrimBody2> trims = new List <NXOpen.Features.TrimBody2>();

            foreach (Face face in faces)
            {
                bool isok;
                NXOpen.Features.TrimBody2 trim = TrimBodyUtils.CreateTrimBodyFeature(face, true, out isok, body);
                if (trim != null)
                {
                    trims.Add(trim);
                    Body temp = trim.GetBodies()[0];
                    if (isok)
                    {
                        body = temp;
                    }
                }
            }
            return(trims);
        }