コード例 #1
0
ファイル: Create.cs プロジェクト: suifengsigan/TEST_1
        /// <summary>
        /// 创建镜像几何体
        /// </summary>
        public static Body Geomcopy(NXOpen.Part workPart, NXOpen.Body body, NXOpen.Plane plane)
        {
            NXOpen.Features.Feature         nullFeatures_Feature = null;
            NXOpen.Features.GeomcopyBuilder geomcopyBuilder1;
            geomcopyBuilder1 = workPart.Features.CreateGeomcopyBuilder(nullFeatures_Feature);

            //选择对象
            geomcopyBuilder1.GeometryToInstance.Add(body);

            //选择平面
            geomcopyBuilder1.MirrorPlane = plane;

            geomcopyBuilder1.Type = NXOpen.Features.GeomcopyBuilder.TransformTypes.Mirror;

            Geomcopy feature1;

            feature1 = geomcopyBuilder1.CommitFeature() as Geomcopy;
            geomcopyBuilder1.Destroy();
            var b = feature1.GetBodies().FirstOrDefault();

            RemoveParameters(new List <Body> {
                b
            });
            return(b);
        }
コード例 #2
0
        /// <summary>
        /// 以面数据创建平面
        /// </summary>
        /// <param name="planeFace"></param>
        /// <returns></returns>
        public static NXOpen.Plane CreatePlaneOfFace(Face face, bool flip)
        {
            Part     workPart = theSession.Parts.Work;
            Point3d  originPt;
            Vector3d normal;

            FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
            NXOpen.Plane plane1 = workPart.Planes.CreatePlane(originPt, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);
            plane1.SetFlip(flip);
            return(plane1);
        }
コード例 #3
0
ファイル: DatumPlane.cs プロジェクト: suifengsigan/TEST_1
        internal static Snap.NX.DatumPlane CreateDatumPlane(Position position, Vector direction)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.DatumPlaneBuilder featureBuilder = workPart.Features.CreateDatumPlaneBuilder(null);
            NXOpen.Plane plane = featureBuilder.GetPlane();
            plane.SetMethod(PlaneTypes.MethodType.PointDir);
            Direction direction2 = Globals.NXOpenWorkPart.Directions.CreateDirection((Point3d)position, (Vector3d)direction, SmartObject.UpdateOption.WithinModeling);

            NXOpen.NXObject[] geom = new NXOpen.NXObject[] { workPart.Points.CreatePoint((Point3d)position), direction2 };
            plane.SetGeometry(geom);
            plane.Evaluate();
            DatumPlaneFeature datumPlaneFeature = (DatumPlaneFeature)Snap.NX.Feature.CommitFeature(featureBuilder);

            featureBuilder.Destroy();
            return(new Snap.NX.DatumPlane(datumPlaneFeature));
        }
コード例 #4
0
ファイル: DatumPlane.cs プロジェクト: suifengsigan/TEST_1
        internal static Snap.NX.DatumPlane CreateDatumPlane(Snap.NX.ICurve curve, Snap.Number arcLength)
        {
            NXOpen.Features.DatumPlaneBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateDatumPlaneBuilder(null);
            NXOpen.Plane plane = featureBuilder.GetPlane();
            plane.SetMethod(PlaneTypes.MethodType.Frenet);
            NXOpen.NXObject[] geom = new NXOpen.NXObject[] { (NXOpen.NXObject)curve.NXOpenICurve };
            plane.SetGeometry(geom);
            plane.SetFrenetSubtype(PlaneTypes.FrenetSubtype.Tangent);
            plane.SetPercent(true);
            plane.SetExpression(arcLength.ToString());
            plane.Evaluate();
            DatumPlaneFeature datumPlaneFeature = (DatumPlaneFeature)Snap.NX.Feature.CommitFeature(featureBuilder);

            featureBuilder.Destroy();
            return(new Snap.NX.DatumPlane(datumPlaneFeature));
        }
コード例 #5
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();
            }
        }
コード例 #6
0
        /// <summary>
        /// 以面中心点和向量创建平面
        /// </summary>
        /// <param name="planeFace"></param>
        /// <param name="flip">设置是否翻转方向</param>
        /// <returns></returns>
        public static NXOpen.Plane CreatePlaneOfFace(Face face, bool flip)
        {
            Part     workPart = theSession.Parts.Work;
            Point3d  originPt;
            Vector3d normal;

            FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
            try
            {
                NXOpen.Plane plane1 = workPart.Planes.CreatePlane(originPt, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);
                plane1.SetFlip(flip);
                return(plane1);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("Basic.TrimBody:CreateTrimBodyFeature:" + ex.Message);
                throw ex;
            }
        }
コード例 #7
0
ファイル: ProjectCurve.cs プロジェクト: suifengsigan/TEST_1
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.DatumPlane datumPlane, Snap.NX.Curve[] curves, Snap.NX.Point[] points)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            //featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
                Point3d helpPoint           = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(rules, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            Position origin = datumPlane.Origin;
            Vector   normal = datumPlane.Normal;

            NXOpen.Plane plane = Globals.NXOpenWorkPart.Planes.CreatePlane((Point3d)origin, (Vector3d)normal, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.PlaneToProjectTo = plane;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
コード例 #8
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.DatumPlane datumPlane)
        {
            NXOpen.Features.ProjectCurveBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
            sectionToProject.AddICurve(curves);
            sectionToProject.AddPoints(points);
            Position origin = datumPlane.Origin;
            Vector   normal = datumPlane.Normal;

            NXOpen.Plane plane = Globals.NXOpenWorkPart.Planes.CreatePlane((Point3d)origin, (Vector3d)normal, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.PlaneToProjectTo = plane;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
コード例 #9
0
ファイル: Create.cs プロジェクト: suifengsigan/TEST_1
        public static Body Geomcopy(NXOpen.Body body, NXOpen.Plane plane)
        {
            var workPart = NXOpen.Session.GetSession().Parts.Work;

            return(Geomcopy(workPart, body, plane));
        }