예제 #1
0
    private void CreateExtrude(IBaseCurve[] curves, bool add, double distance, Vector3d vector)
    {
        SelectionIntentRule[] rules = new SelectionIntentRule[1]
        {
            workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves)
        };

        NXOpen.Features.ExtrudeBuilder extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(null);
        NXOpen.Section section1 = workPart.Sections.CreateSection(0.0095, 0.01, 0.5);
        section1.AddToSection(rules, (Curve)curves[0], null, null, new Point3d(0, 0, 0), Section.Mode.Create, false);
        extrudeBuilder1.Section = section1;

        if (add)
        {
            extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
        }
        else
        {
            extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract;

            extrudeBuilder1.BooleanOperation.SetTargetBodies(new Body[1] {
                workPart.Bodies.ToArray()[0]
            });
        }
        distance = distance / 2.0;
        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "-" + distance.ToString();
        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide   = distance.ToString();

        NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0, 0);
        extrudeBuilder1.Direction = workPart.Directions.CreateDirection(origin1, vector, NXOpen.SmartObject.UpdateOption.WithinModeling);

        extrudeBuilder1.CommitFeature();

        extrudeBuilder1.Destroy();
    }
예제 #2
0
        /// <summary>
        /// 获得两个点的矢量 p1->p2
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        public static Vector3d GetVector(NXOpen.Point3d p1, NXOpen.Point3d p2)
        {
            Vector3d vector = new Vector3d();

            vector.X = p2.X - p1.X;
            vector.Y = p2.Y - p1.Y;
            vector.Z = p2.Z - p1.Z;

            return(GetNorm(vector));
        }
예제 #3
0
        internal static IEnumerable <IGH_Goo> PromptBox(string prompt)
        {
            IGH_Goo goo = null;

            if (PickPointOnFace(prompt + " : First box corner - ", out var from) &&
                PickPointOnFace(prompt + " : Second box corner - ", out var to))
            {
                var min = new NXOpen.Point3d(Math.Min(from.X, to.X), Math.Min(from.Y, to.Y), Math.Min(from.Z, to.Z));
                var max = new NXOpen.Point3d(Math.Max(from.X, to.X), Math.Max(from.Y, to.Y), Math.Max(from.Z, to.Z));

                goo = new GH_Box(new Rhino.Geometry.BoundingBox(min.ToRhino(), max.ToRhino()));
            }

            yield return(goo);
        }
예제 #4
0
        internal static bool PickPointOnFace(string prompt, out NXOpen.Point3d point)
        {
            point = default;

            double[] pt = new double[3];
            if (theUfSession.Ui.PointSubfunction("Please pick a point on the face", new int[] { 14, 0 }, 0, pt) == 5)
            {
                point = new NXOpen.Point3d(pt[0], pt[1], pt[2]);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        internal static bool PickPoint(string prompt, out NXOpen.Point3d point)
        {
            point = default;

            double[] pt = new double[3];

            if (theUfSession.Ui.PointSubfunction(prompt + " : First box corner - ", new int[] { 0, 1 }, 0, pt) == 5)
            {
                point = new NXOpen.Point3d(pt[0], pt[1], pt[2]);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
    void PlaceDefaultPos(BasePart baseprt, string partpath)
    {
        Point3d   basePoint   = new NXOpen.Point3d(0.0, 0.0, 0.0);
        Matrix3x3 orientation = new NXOpen.Matrix3x3();

        orientation.Xx = 0; orientation.Xy = 0.0; orientation.Xz = -1;
        orientation.Yx = 0.0; orientation.Yy = 1; orientation.Yz = 0;
        orientation.Zx = 1; orientation.Zy = 0; orientation.Zz = 0;

        string partname = Path.GetFileNameWithoutExtension(partpath);

        PartLoadStatus partLoadStatus1;
        Component      component1;

        component1 = baseprt.ComponentAssembly.AddComponent(partpath, "Entire Part", partname, basePoint, orientation, -1, out partLoadStatus1, true);
    }
예제 #7
0
        public static NXObject CreatePullFace(Vector3d vec, double pull, params Face[] faces)
        {
            Session theSession = Session.GetSession();
            Part    workPart   = theSession.Parts.Work;

            NXOpen.Features.PullFace        nullNXOpen_Features_PullFace = null;
            NXOpen.Features.PullFaceBuilder pullFaceBuilder1;
            pullFaceBuilder1 = workPart.Features.CreatePullFaceBuilder(nullNXOpen_Features_PullFace);

            pullFaceBuilder1.Motion.DistanceAngle.OrientXpress.AxisOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Axis.Passive;

            pullFaceBuilder1.Motion.DistanceAngle.OrientXpress.PlaneOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Plane.Passive;

            pullFaceBuilder1.Motion.AlongCurveAngle.AlongCurve.IsPercentUsed = true;

            NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);

            NXOpen.Direction direction1;
            direction1 = workPart.Directions.CreateDirection(origin1, vec, NXOpen.SmartObject.UpdateOption.WithinModeling);

            pullFaceBuilder1.Motion.DistanceVector = direction1;

            NXOpen.FaceDumbRule faceDumbRule;
            faceDumbRule = workPart.ScRuleFactory.CreateRuleFaceDumb(faces);

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
            rules1[0] = faceDumbRule;
            pullFaceBuilder1.FaceToPull.ReplaceRules(rules1, false);

            pullFaceBuilder1.Motion.DistanceValue.RightHandSide = pull.ToString();

            try
            {
                NXOpen.NXObject nXObject1;
                nXObject1 = pullFaceBuilder1.Commit();
                return(nXObject1);
            }
            catch (Exception ex)
            {
                LogMgr.WriteLog("PullFaceUtils:CreatePullFace:      " + ex.Message);
                return(null);
            }
            finally
            {
                pullFaceBuilder1.Destroy();
            }
        }
예제 #8
0
        /// <summary>
        /// 创建尺寸约束
        /// </summary>
        /// <param name="line1"></param>
        /// <param name="line2"></param>
        /// <param name="dimOrigin"></param>
        /// <param name="method"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static Expression CreateDimForLine(Line line1, Line line2, double[] dimOrigin, NXOpen.Annotations.DimensionMeasurementBuilder.MeasurementMethod method, InferSnapType.SnapType type)
        {
            Part workPart = theSession.Parts.Work;

            NXOpen.Annotations.Dimension        nullNXOpen_Annotations_Dimension = null;
            NXOpen.SketchLinearDimensionBuilder sketchLinearDimensionBuilder1;
            sketchLinearDimensionBuilder1 = workPart.Sketches.CreateLinearDimensionBuilder(nullNXOpen_Annotations_Dimension);
            sketchLinearDimensionBuilder1.Origin.SetInferRelativeToGeometry(true);                                                      //如果未应用其他关联性,则在提交时推断关联几何关系
            sketchLinearDimensionBuilder1.Measurement.Method       = method;                                                            //测量方向
            sketchLinearDimensionBuilder1.Driving.DrivingMethod    = NXOpen.Annotations.DrivingValueBuilder.DrivingValueMethod.Driving; //驱动方法
            sketchLinearDimensionBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane;           //平面类型
            NXOpen.Direction nullNXOpen_Direction = null;
            sketchLinearDimensionBuilder1.Measurement.Direction = nullNXOpen_Direction;                                                 //测量方向
            NXOpen.View nullNXOpen_View = null;
            sketchLinearDimensionBuilder1.Measurement.DirectionView = nullNXOpen_View;                                                  //测量视图
            sketchLinearDimensionBuilder1.Style.DimensionStyle.NarrowDisplayType = NXOpen.Annotations.NarrowDisplayOption.None;         //设置窄尺寸样式
            NXOpen.Point3d point2_3 = new NXOpen.Point3d(0.0, 0.0, 0.0);
            sketchLinearDimensionBuilder1.SecondAssociativity.SetValue(NXOpen.InferSnapType.SnapType.Mid, line2, workPart.ModelingViews.WorkView, line2.EndPoint, null, nullNXOpen_View, point2_3);

            NXOpen.Point3d point2_4 = new NXOpen.Point3d(0.0, 0.0, 0.0);
            sketchLinearDimensionBuilder1.FirstAssociativity.SetValue(type, line1, workPart.ModelingViews.WorkView, line1.EndPoint, null, nullNXOpen_View, point2_4);
            NXOpen.Point3d point3 = new NXOpen.Point3d(dimOrigin[0], dimOrigin[1], dimOrigin[2]);
            sketchLinearDimensionBuilder1.Origin.Origin.SetValue(null, nullNXOpen_View, point3);

            try
            {
                NXOpen.NXObject nXObject1;
                nXObject1 = sketchLinearDimensionBuilder1.Commit();
                Expression exp = sketchLinearDimensionBuilder1.Driving.ExpressionValue;
                return(exp);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("SketchUtils:CreateDimForLine:" + ex.Message);
                throw ex;
            }
            finally
            {
                sketchLinearDimensionBuilder1.Destroy();
            }
        }
예제 #9
0
        /// <summary>
        /// 创建拉伸特征
        /// </summary>
        /// <param name="vec">向量</param>
        /// <param name="start">起始</param>
        /// <param name="end">终止</param>
        /// <param name="extrude">lastez</param>
        /// <param name="line">线</param>
        /// <returns></returns>
        public static NXOpen.Features.Feature CreateExtrude(Vector3d vec, string start, string end, NXOpen.Features.Feature extrude = null, params TaggedObject[] line)
        {
            Session theSession         = Session.GetSession();
            Part    workPart           = theSession.Parts.Work;
            SelectionRuleFactory rules = new SelectionRuleFactory(line.ToList());

            NXOpen.Features.Feature        nullNXOpen_Features_Feature = null;
            NXOpen.Features.ExtrudeBuilder extrudeBuilder1             = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature);
            NXOpen.Section section1 = workPart.Sections.CreateSection();
            extrudeBuilder1.Section = section1;
            extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = start;
            extrudeBuilder1.Limits.EndExtend.Value.RightHandSide   = end;

            NXOpen.Point3d   origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
            NXOpen.Direction direction1;
            direction1 = workPart.Directions.CreateDirection(origin1, vec, NXOpen.SmartObject.UpdateOption.WithinModeling);


            NXOpen.NXObject nullNXOpen_NXObject = null;

            section1.AddToSection(rules.CreateSelectionRule().ToArray(), (NXObject)line[0], nullNXOpen_NXObject, nullNXOpen_NXObject, origin1, NXOpen.Section.Mode.Create, false);
            extrudeBuilder1.Direction = direction1;
            NXOpen.Session.UndoMarkId markId = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start Extruded");
            try
            {
                return(extrudeBuilder1.CommitFeature());
            }

            catch (NXException ex)
            {
                LogMgr.WriteLog("ExtrudedUtils:CreateExtruded:" + ex.Message);
                throw ex;
            }
            finally
            {
                extrudeBuilder1.Destroy();
                theSession.UpdateManager.DoUpdate(markId);
                theSession.DeleteUndoMark(markId, "End Extruded");
            }
        }
예제 #10
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Starting NX Golden Cantilever Journal");

        //Declare Part Variables
        //Convert Strings to doubles from the args
        double heightA   = System.Convert.ToDouble(args[0]);
        double length    = System.Convert.ToDouble(args[1]);
        double thickness = System.Convert.ToDouble(args[2]);


        //Declare part name for the part file and the IGES file
        string part_name     = args[3];
        string part_name_prt = part_name + ".prt";
        string part_name_igs = part_name + ".igs";

        //Measurements need to be converted from m to mm
        //length = 1000 * length;
        //thickness = 1000 * thickness;
        //heightA = 1000 * heightA;
        double heightB = 1.618 * heightA;


        //Convert necessary values back to strings because I already
        //converted them to doubles and I'm too lazy to go back and change
        //this since it works.
        string length_string    = System.Convert.ToString(length);
        string thickness_string = System.Convert.ToString(thickness);
        string heightA_string   = System.Convert.ToString(heightA);
        string heightB_string   = System.Convert.ToString(heightB);

        NXOpen.Session theSession = NXOpen.Session.GetSession();
        // ----------------------------------------------
        //   Menu: File->New...
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId1;
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");

        NXOpen.FileNew fileNew1;
        fileNew1 = theSession.Parts.FileNew();

        theSession.SetUndoMarkName(markId1, "New Dialog");

        NXOpen.Session.UndoMarkId markId2;
        markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "New");

        theSession.DeleteUndoMark(markId2, null);

        NXOpen.Session.UndoMarkId markId3;
        markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "New");

        fileNew1.TemplateFileName = "model-plain-1-mm-template.prt";

        fileNew1.UseBlankTemplate = false;

        fileNew1.ApplicationName = "ModelTemplate";

        fileNew1.Units = NXOpen.Part.Units.Millimeters;

        fileNew1.RelationType = "";

        fileNew1.UsesMasterModel = "No";

        fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item;

        fileNew1.TemplatePresentationName = "Model";

        fileNew1.ItemType = "";

        fileNew1.Specialization = "";

        fileNew1.SetCanCreateAltrep(false);

        fileNew1.NewFileName = part_name_prt;

        fileNew1.MasterFileName = "";

        fileNew1.MakeDisplayedPart = true;

        NXOpen.NXObject nXObject1;
        nXObject1 = fileNew1.Commit();

        NXOpen.Part workPart    = theSession.Parts.Work;
        NXOpen.Part displayPart = theSession.Parts.Display;
        theSession.DeleteUndoMark(markId3, null);

        fileNew1.Destroy();

        theSession.ApplicationSwitchImmediate("UG_APP_MODELING");

        NXOpen.Session.UndoMarkId markId4;
        markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Enter Gateway");

        NXOpen.Session.UndoMarkId markId5;
        markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Enter Modeling");

        // ----------------------------------------------
        //   Menu: Insert->Sketch...
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId6;
        markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");

        NXOpen.Sketch nullNXOpen_Sketch = null;
        NXOpen.SketchInPlaceBuilder sketchInPlaceBuilder1;
        sketchInPlaceBuilder1 = workPart.Sketches.CreateNewSketchInPlaceBuilder(nullNXOpen_Sketch);

        NXOpen.Unit       unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
        NXOpen.Expression expression1;
        expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

        NXOpen.Expression expression2;
        expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

        NXOpen.SketchAlongPathBuilder sketchAlongPathBuilder1;
        sketchAlongPathBuilder1 = workPart.Sketches.CreateSketchAlongPathBuilder(nullNXOpen_Sketch);

        sketchAlongPathBuilder1.PlaneLocation.Expression.RightHandSide = "0";

        theSession.SetUndoMarkName(markId6, "Create Sketch Dialog");

        NXOpen.DatumPlane datumPlane1 = (NXOpen.DatumPlane)workPart.Datums.FindObject("DATUM_CSYS(0) YZ plane");
        NXOpen.Point3d    point1      = new NXOpen.Point3d(11.1863449593062, 6.4875984180345, 0.0);
        sketchInPlaceBuilder1.PlaneOrFace.SetValue(datumPlane1, workPart.ModelingViews.WorkView, point1);

        NXOpen.Features.DatumCsys datumCsys1 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject("DATUM_CSYS(0)");
        NXOpen.Point point2 = (NXOpen.Point)datumCsys1.FindObject("POINT 1");
        sketchInPlaceBuilder1.SketchOrigin = point2;

        sketchInPlaceBuilder1.PlaneOrFace.Value = null;

        sketchInPlaceBuilder1.PlaneOrFace.Value = datumPlane1;

        NXOpen.DatumAxis datumAxis1 = (NXOpen.DatumAxis)workPart.Datums.FindObject("DATUM_CSYS(0) X axis");
        sketchInPlaceBuilder1.Axis.Value = datumAxis1;

        NXOpen.Session.UndoMarkId markId7;
        markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Create Sketch");

        theSession.DeleteUndoMark(markId7, null);

        NXOpen.Session.UndoMarkId markId8;
        markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Create Sketch");

        theSession.Preferences.Sketch.CreateInferredConstraints = true;

        theSession.Preferences.Sketch.ContinuousAutoDimensioning = true;

        theSession.Preferences.Sketch.DimensionLabel = NXOpen.Preferences.SketchPreferences.DimensionLabelType.Expression;

        theSession.Preferences.Sketch.TextSizeFixed = true;

        theSession.Preferences.Sketch.FixedTextSize = 3.0;

        theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0;

        theSession.Preferences.Sketch.DisplayObjectColor = false;

        theSession.Preferences.Sketch.DisplayObjectName = true;

        NXOpen.NXObject nXObject2;
        nXObject2 = sketchInPlaceBuilder1.Commit();

        NXOpen.Sketch           sketch1 = (NXOpen.Sketch)nXObject2;
        NXOpen.Features.Feature feature1;
        feature1 = sketch1.Feature;

        NXOpen.Session.UndoMarkId markId9;
        markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "update");

        int nErrs1;

        nErrs1 = theSession.UpdateManager.DoUpdate(markId9);

        sketch1.Activate(NXOpen.Sketch.ViewReorient.True);

        theSession.DeleteUndoMark(markId8, null);

        theSession.SetUndoMarkName(markId6, "Create Sketch");

        sketchInPlaceBuilder1.Destroy();

        sketchAlongPathBuilder1.Destroy();

        try
        {
            // Expression is still in use.
            workPart.Expressions.Delete(expression2);
        }
        catch (NXException ex)
        {
            ex.AssertErrorCode(1050029);
        }

        try
        {
            // Expression is still in use.
            workPart.Expressions.Delete(expression1);
        }
        catch (NXException ex)
        {
            ex.AssertErrorCode(1050029);
        }

        // ----------------------------------------------
        //   Menu: Insert->Sketch Curve->Line...
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId10;
        markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Profile short list");

        NXOpen.Session.UndoMarkId markId11;
        markId11 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Curve");

        NXOpen.Expression expression3;
        expression3 = workPart.Expressions.CreateSystemExpression(length_string);

        theSession.SetUndoMarkVisibility(markId11, "Curve", NXOpen.Session.MarkVisibility.Visible);

        NXOpen.Point3d startPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
        NXOpen.Point3d endPoint1   = new NXOpen.Point3d(length, 0.0, 0.0);
        NXOpen.Line    line1;
        line1 = workPart.Curves.CreateLine(startPoint1, endPoint1);

        theSession.ActiveSketch.AddGeometry(line1, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        NXOpen.Sketch.ConstraintGeometry geom1_1 = new NXOpen.Sketch.ConstraintGeometry();
        geom1_1.Geometry  = line1;
        geom1_1.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex;
        geom1_1.SplineDefiningPointIndex = 0;
        NXOpen.Sketch.ConstraintGeometry geom2_1    = new NXOpen.Sketch.ConstraintGeometry();
        NXOpen.Features.DatumCsys        datumCsys2 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject("SKETCH(1:1B)");
        NXOpen.Point point3 = (NXOpen.Point)datumCsys2.FindObject("POINT 1");
        geom2_1.Geometry  = point3;
        geom2_1.PointType = NXOpen.Sketch.ConstraintPointType.None;
        geom2_1.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint1;
        sketchGeometricConstraint1 = theSession.ActiveSketch.CreateCoincidentConstraint(geom1_1, geom2_1);

        NXOpen.Sketch.ConstraintGeometry geom1 = new NXOpen.Sketch.ConstraintGeometry();
        geom1.Geometry  = line1;
        geom1.PointType = NXOpen.Sketch.ConstraintPointType.None;
        geom1.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint2;
        sketchGeometricConstraint2 = theSession.ActiveSketch.CreateHorizontalConstraint(geom1);

        NXOpen.Sketch.DimensionGeometry dimObject1_1 = new NXOpen.Sketch.DimensionGeometry();
        dimObject1_1.Geometry    = line1;
        dimObject1_1.AssocType   = NXOpen.Sketch.AssocType.StartPoint;
        dimObject1_1.AssocValue  = 0;
        dimObject1_1.HelpPoint.X = 0.0;
        dimObject1_1.HelpPoint.Y = 0.0;
        dimObject1_1.HelpPoint.Z = 0.0;
        NXOpen.NXObject nullNXOpen_NXObject = null;
        dimObject1_1.View = nullNXOpen_NXObject;
        NXOpen.Sketch.DimensionGeometry dimObject2_1 = new NXOpen.Sketch.DimensionGeometry();
        dimObject2_1.Geometry    = line1;
        dimObject2_1.AssocType   = NXOpen.Sketch.AssocType.EndPoint;
        dimObject2_1.AssocValue  = 0;
        dimObject2_1.HelpPoint.X = 0.0;
        dimObject2_1.HelpPoint.Y = 0.0;
        dimObject2_1.HelpPoint.Z = 0.0;
        dimObject2_1.View        = nullNXOpen_NXObject;
        NXOpen.Point3d dimOrigin1 = new NXOpen.Point3d(45.0, -9.0598069411704, 0.0);
        NXOpen.SketchDimensionalConstraint sketchDimensionalConstraint1;
        sketchDimensionalConstraint1 = theSession.ActiveSketch.CreateDimension(NXOpen.Sketch.ConstraintType.ParallelDim, dimObject1_1, dimObject2_1, dimOrigin1, expression3, NXOpen.Sketch.DimensionOption.CreateAsDriving);

        NXOpen.SketchHelpedDimensionalConstraint sketchHelpedDimensionalConstraint1 = (NXOpen.SketchHelpedDimensionalConstraint)sketchDimensionalConstraint1;
        NXOpen.Annotations.Dimension             dimension1;
        dimension1 = sketchHelpedDimensionalConstraint1.AssociatedDimension;

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId12;
        markId12 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Curve");

        NXOpen.Expression expression4;
        expression4 = workPart.Expressions.CreateSystemExpression(heightA_string);

        NXOpen.Expression expression5;
        expression5 = workPart.Expressions.CreateSystemExpression(length_string);

        workPart.Expressions.Edit(expression4, heightA_string);

        theSession.SetUndoMarkVisibility(markId12, "Curve", NXOpen.Session.MarkVisibility.Visible);

        NXOpen.Point3d startPoint2 = new NXOpen.Point3d(length, 0.0, 0.0);
        NXOpen.Point3d endPoint2   = new NXOpen.Point3d(length, heightA, 0.0);
        NXOpen.Line    line2;
        line2 = workPart.Curves.CreateLine(startPoint2, endPoint2);

        theSession.ActiveSketch.AddGeometry(line2, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        NXOpen.Sketch.ConstraintGeometry geom1_2 = new NXOpen.Sketch.ConstraintGeometry();
        geom1_2.Geometry  = line2;
        geom1_2.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex;
        geom1_2.SplineDefiningPointIndex = 0;
        NXOpen.Sketch.ConstraintGeometry geom2_2 = new NXOpen.Sketch.ConstraintGeometry();
        geom2_2.Geometry  = line1;
        geom2_2.PointType = NXOpen.Sketch.ConstraintPointType.EndVertex;
        geom2_2.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint3;
        sketchGeometricConstraint3 = theSession.ActiveSketch.CreateCoincidentConstraint(geom1_2, geom2_2);

        NXOpen.Sketch.ConstraintGeometry geom2 = new NXOpen.Sketch.ConstraintGeometry();
        geom2.Geometry  = line2;
        geom2.PointType = NXOpen.Sketch.ConstraintPointType.None;
        geom2.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint4;
        sketchGeometricConstraint4 = theSession.ActiveSketch.CreateVerticalConstraint(geom2);

        workPart.Expressions.Delete(expression5);

        NXOpen.Sketch.DimensionGeometry dimObject1_2 = new NXOpen.Sketch.DimensionGeometry();
        dimObject1_2.Geometry    = line2;
        dimObject1_2.AssocType   = NXOpen.Sketch.AssocType.StartPoint;
        dimObject1_2.AssocValue  = 0;
        dimObject1_2.HelpPoint.X = 0.0;
        dimObject1_2.HelpPoint.Y = 0.0;
        dimObject1_2.HelpPoint.Z = 0.0;
        dimObject1_2.View        = nullNXOpen_NXObject;
        NXOpen.Sketch.DimensionGeometry dimObject2_2 = new NXOpen.Sketch.DimensionGeometry();
        dimObject2_2.Geometry    = line2;
        dimObject2_2.AssocType   = NXOpen.Sketch.AssocType.EndPoint;
        dimObject2_2.AssocValue  = 0;
        dimObject2_2.HelpPoint.X = 0.0;
        dimObject2_2.HelpPoint.Y = 0.0;
        dimObject2_2.HelpPoint.Z = 0.0;
        dimObject2_2.View        = nullNXOpen_NXObject;
        NXOpen.Point3d dimOrigin2 = new NXOpen.Point3d(99.0598069411704, 15.0, 0.0);
        NXOpen.SketchDimensionalConstraint sketchDimensionalConstraint2;
        sketchDimensionalConstraint2 = theSession.ActiveSketch.CreateDimension(NXOpen.Sketch.ConstraintType.ParallelDim, dimObject1_2, dimObject2_2, dimOrigin2, expression4, NXOpen.Sketch.DimensionOption.CreateAsDriving);

        NXOpen.SketchHelpedDimensionalConstraint sketchHelpedDimensionalConstraint2 = (NXOpen.SketchHelpedDimensionalConstraint)sketchDimensionalConstraint2;
        NXOpen.Annotations.Dimension             dimension2;
        dimension2 = sketchHelpedDimensionalConstraint2.AssociatedDimension;

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId13;
        markId13 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Curve");

        NXOpen.Expression expression6;
        expression6 = workPart.Expressions.CreateSystemExpression(heightB_string);

        NXOpen.Expression expression7;
        expression7 = workPart.Expressions.CreateSystemExpression(length_string);

        theSession.SetUndoMarkVisibility(markId13, "Curve", NXOpen.Session.MarkVisibility.Visible);

        NXOpen.Point3d startPoint3 = new NXOpen.Point3d(0.0, 0.0, 0.0);
        NXOpen.Point3d endPoint3   = new NXOpen.Point3d(7.02873218749514e-014, heightB, 0.0);
        NXOpen.Line    line3;
        line3 = workPart.Curves.CreateLine(startPoint3, endPoint3);

        theSession.ActiveSketch.AddGeometry(line3, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        NXOpen.Sketch.ConstraintGeometry geom1_3 = new NXOpen.Sketch.ConstraintGeometry();
        geom1_3.Geometry  = line3;
        geom1_3.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex;
        geom1_3.SplineDefiningPointIndex = 0;
        NXOpen.Sketch.ConstraintGeometry geom2_3 = new NXOpen.Sketch.ConstraintGeometry();
        geom2_3.Geometry  = line1;
        geom2_3.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex;
        geom2_3.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint5;
        sketchGeometricConstraint5 = theSession.ActiveSketch.CreateCoincidentConstraint(geom1_3, geom2_3);

        NXOpen.Sketch.ConstraintGeometry geom3 = new NXOpen.Sketch.ConstraintGeometry();
        geom3.Geometry  = line3;
        geom3.PointType = NXOpen.Sketch.ConstraintPointType.None;
        geom3.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint6;
        sketchGeometricConstraint6 = theSession.ActiveSketch.CreateVerticalConstraint(geom3);

        workPart.Expressions.Delete(expression7);

        NXOpen.Sketch.DimensionGeometry dimObject1_3 = new NXOpen.Sketch.DimensionGeometry();
        dimObject1_3.Geometry    = line3;
        dimObject1_3.AssocType   = NXOpen.Sketch.AssocType.StartPoint;
        dimObject1_3.AssocValue  = 0;
        dimObject1_3.HelpPoint.X = 0.0;
        dimObject1_3.HelpPoint.Y = 0.0;
        dimObject1_3.HelpPoint.Z = 0.0;
        dimObject1_3.View        = nullNXOpen_NXObject;
        NXOpen.Sketch.DimensionGeometry dimObject2_3 = new NXOpen.Sketch.DimensionGeometry();
        dimObject2_3.Geometry    = line3;
        dimObject2_3.AssocType   = NXOpen.Sketch.AssocType.EndPoint;
        dimObject2_3.AssocValue  = 0;
        dimObject2_3.HelpPoint.X = 0.0;
        dimObject2_3.HelpPoint.Y = 0.0;
        dimObject2_3.HelpPoint.Z = 0.0;
        dimObject2_3.View        = nullNXOpen_NXObject;
        NXOpen.Point3d dimOrigin3 = new NXOpen.Point3d(9.05980694117043, heightA, 0.0);
        NXOpen.SketchDimensionalConstraint sketchDimensionalConstraint3;
        sketchDimensionalConstraint3 = theSession.ActiveSketch.CreateDimension(NXOpen.Sketch.ConstraintType.ParallelDim, dimObject1_3, dimObject2_3, dimOrigin3, expression6, NXOpen.Sketch.DimensionOption.CreateAsDriving);

        NXOpen.SketchHelpedDimensionalConstraint sketchHelpedDimensionalConstraint3 = (NXOpen.SketchHelpedDimensionalConstraint)sketchDimensionalConstraint3;
        NXOpen.Annotations.Dimension             dimension3;
        dimension3 = sketchHelpedDimensionalConstraint3.AssociatedDimension;

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId14;
        markId14 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Curve");

        theSession.SetUndoMarkVisibility(markId14, "Curve", NXOpen.Session.MarkVisibility.Visible);

        NXOpen.Point3d startPoint4 = new NXOpen.Point3d(0.0, heightB, 0.0);
        NXOpen.Point3d endPoint4   = new NXOpen.Point3d(length, heightA, 0.0);
        //NXOpen.Point3d endPoint4 = new NXOpen.Point3d(90.0, 29.9999999999998, 0.0);
        NXOpen.Line line4;
        line4 = workPart.Curves.CreateLine(startPoint4, endPoint4);

        theSession.ActiveSketch.AddGeometry(line4, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        NXOpen.Sketch.ConstraintGeometry geom1_4 = new NXOpen.Sketch.ConstraintGeometry();
        geom1_4.Geometry  = line4;
        geom1_4.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex;
        geom1_4.SplineDefiningPointIndex = 0;
        NXOpen.Sketch.ConstraintGeometry geom2_4 = new NXOpen.Sketch.ConstraintGeometry();
        geom2_4.Geometry  = line3;
        geom2_4.PointType = NXOpen.Sketch.ConstraintPointType.EndVertex;
        geom2_4.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint7;
        sketchGeometricConstraint7 = theSession.ActiveSketch.CreateCoincidentConstraint(geom1_4, geom2_4);

        NXOpen.Sketch.ConstraintGeometry geom1_5 = new NXOpen.Sketch.ConstraintGeometry();
        geom1_5.Geometry  = line4;
        geom1_5.PointType = NXOpen.Sketch.ConstraintPointType.EndVertex;
        geom1_5.SplineDefiningPointIndex = 0;
        NXOpen.Sketch.ConstraintGeometry geom2_5 = new NXOpen.Sketch.ConstraintGeometry();
        geom2_5.Geometry  = line2;
        geom2_5.PointType = NXOpen.Sketch.ConstraintPointType.EndVertex;
        geom2_5.SplineDefiningPointIndex = 0;
        NXOpen.SketchGeometricConstraint sketchGeometricConstraint8;
        sketchGeometricConstraint8 = theSession.ActiveSketch.CreateCoincidentConstraint(geom1_5, geom2_5);

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        // ----------------------------------------------
        //   Menu: File->Finish Sketch
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId15;
        markId15 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Deactivate Sketch");

        theSession.ActiveSketch.Deactivate(NXOpen.Sketch.ViewReorient.False, NXOpen.Sketch.UpdateLevel.Model);

        // ----------------------------------------------
        //   Menu: Insert->Design Feature->Extrude...
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId16;
        markId16 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");

        NXOpen.Features.Feature nullNXOpen_Features_Feature = null;

        if (!workPart.Preferences.Modeling.GetHistoryMode())
        {
            throw new Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode.");
        }

        NXOpen.Features.ExtrudeBuilder extrudeBuilder1;
        extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature);

        NXOpen.Section section1;
        section1 = workPart.Sections.CreateSection(0.0095, 0.01, 0.5);

        extrudeBuilder1.Section = section1;

        extrudeBuilder1.AllowSelfIntersectingSection(true);

        NXOpen.Unit unit2;
        unit2 = extrudeBuilder1.Draft.FrontDraftAngle.Units;

        NXOpen.Expression expression8;
        expression8 = workPart.Expressions.CreateSystemExpressionWithUnits("2.00", unit2);

        extrudeBuilder1.DistanceTolerance = 0.01;

        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

        NXOpen.Body[] targetBodies1   = new NXOpen.Body[1];
        NXOpen.Body   nullNXOpen_Body = null;
        targetBodies1[0] = nullNXOpen_Body;
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1);

        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0";

        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = "25";

        extrudeBuilder1.Offset.StartOffset.RightHandSide = "0";

        extrudeBuilder1.Offset.EndOffset.RightHandSide = "5";

        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0";

        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = thickness_string;

        extrudeBuilder1.Draft.FrontDraftAngle.RightHandSide = "2";

        extrudeBuilder1.Draft.BackDraftAngle.RightHandSide = "2";

        extrudeBuilder1.Offset.StartOffset.RightHandSide = "0";

        extrudeBuilder1.Offset.EndOffset.RightHandSide = "5";

        NXOpen.GeometricUtilities.SmartVolumeProfileBuilder smartVolumeProfileBuilder1;
        smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile;

        smartVolumeProfileBuilder1.OpenProfileSmartVolumeOption = false;

        smartVolumeProfileBuilder1.CloseProfileRule = NXOpen.GeometricUtilities.SmartVolumeProfileBuilder.CloseProfileRuleType.Fci;

        theSession.SetUndoMarkName(markId16, "Extrude Dialog");

        section1.DistanceTolerance = 0.01;

        section1.ChainingTolerance = 0.0095;

        section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);

        NXOpen.Session.UndoMarkId markId17;
        markId17 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "section mark");

        NXOpen.Session.UndoMarkId markId18;
        markId18 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, null);

        NXOpen.Features.Feature[]     features1      = new NXOpen.Features.Feature[1];
        NXOpen.Features.SketchFeature sketchFeature1 = (NXOpen.Features.SketchFeature)feature1;
        features1[0] = sketchFeature1;
        NXOpen.CurveFeatureRule curveFeatureRule1;
        curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features1);

        section1.AllowSelfIntersection(true);

        NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
        rules1[0] = curveFeatureRule1;
        NXOpen.Point3d helpPoint1 = new NXOpen.Point3d(53.8762063337749, 42.0412645554082, 0.0);
        section1.AddToSection(rules1, line4, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, false);

        theSession.DeleteUndoMark(markId18, null);

        NXOpen.Direction direction1;
        direction1 = workPart.Directions.CreateDirection(sketch1, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.WithinModeling);

        extrudeBuilder1.Direction = direction1;

        theSession.DeleteUndoMark(markId17, null);

        NXOpen.Session.UndoMarkId markId19;
        markId19 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Extrude");

        theSession.DeleteUndoMark(markId19, null);

        NXOpen.Session.UndoMarkId markId20;
        markId20 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Extrude");

        extrudeBuilder1.ParentFeatureInternal = false;

        NXOpen.Features.Feature feature2;
        feature2 = extrudeBuilder1.CommitFeature();

        theSession.DeleteUndoMark(markId20, null);

        theSession.SetUndoMarkName(markId16, "Extrude");

        NXOpen.Expression expression9  = extrudeBuilder1.Limits.StartExtend.Value;
        NXOpen.Expression expression10 = extrudeBuilder1.Limits.EndExtend.Value;
        extrudeBuilder1.Destroy();

        workPart.Expressions.Delete(expression8);

        // ----------------------------------------------
        //   Menu: File->Save
        // ----------------------------------------------
        NXOpen.PartSaveStatus partSaveStatus1;
        partSaveStatus1 = workPart.Save(NXOpen.BasePart.SaveComponents.True, NXOpen.BasePart.CloseAfterSave.False);

        partSaveStatus1.Dispose();
        // ----------------------------------------------
        //   Menu: File->Export->IGES...
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId21;
        markId21 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");

        NXOpen.IgesCreator igesCreator1;
        igesCreator1 = theSession.DexManager.CreateIgesCreator();

        igesCreator1.ExportModelData = true;

        igesCreator1.ExportDrawings = true;

        igesCreator1.MapTabCylToBSurf = true;

        igesCreator1.BcurveTol = 0.0508;

        igesCreator1.IdenticalPointResolution = 0.001;

        igesCreator1.MaxThreeDMdlSpace = 10000.0;

        igesCreator1.ObjectTypes.Curves = true;

        igesCreator1.ObjectTypes.Surfaces = true;

        igesCreator1.ObjectTypes.Annotations = true;

        igesCreator1.ObjectTypes.Structures = true;

        igesCreator1.ObjectTypes.Solids = true;

        igesCreator1.OutputFile = part_name_igs;

        igesCreator1.SettingsFile = "C:\\Program Files\\Siemens\\NX 10.0\\iges\\igesexport.def";

        igesCreator1.MaxLineThickness = 2.0;

        igesCreator1.SysDefmaxThreeDMdlSpace = true;

        igesCreator1.SysDefidenticalPointResolution = true;

        igesCreator1.InputFile = part_name_prt;

        igesCreator1.OutputFile = part_name_igs;

        theSession.SetUndoMarkName(markId21, "Export to IGES Options Dialog");

        igesCreator1.OutputFile = part_name_igs;

        NXOpen.Session.UndoMarkId markId22;
        markId22 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Export to IGES Options");

        theSession.DeleteUndoMark(markId22, null);

        NXOpen.Session.UndoMarkId markId23;
        markId23 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Export to IGES Options");

        igesCreator1.FileSaveFlag = false;

        igesCreator1.LayerMask = "1-256";

        igesCreator1.DrawingList = "";

        igesCreator1.ViewList = "Top,Front,Right,Back,Bottom,Left,Isometric,Trimetric,User Defined";

        NXOpen.NXObject nXObject3;
        nXObject3 = igesCreator1.Commit();

        theSession.DeleteUndoMark(markId23, null);

        theSession.SetUndoMarkName(markId21, "Export to IGES Options");

        igesCreator1.Destroy();

        // ----------------------------------------------
        //   Menu: Tools->Journal->Stop Recording
        // ----------------------------------------------

        Console.WriteLine("Finishing NX Golden Cantilever Journal");
    }
예제 #11
0
    public static void Main(string[] args)
    {
        NXOpen.Session           theSession     = NXOpen.Session.GetSession();
        NXOpen.Part              workPart       = theSession.Parts.Work;
        NXOpen.Part              displayPart    = theSession.Parts.Display;
        NXOpen.CAM.PlanarMilling planarMilling1 = (NXOpen.CAM.PlanarMilling)workPart.CAMSetup.CAMOperationCollection.FindObject("PLANAR_MILL");
        theSession.CAMSession.PathDisplay.ShowToolPath(planarMilling1);

        theSession.CAMSession.PathDisplay.HideToolPath(planarMilling1);

        NXOpen.Session.UndoMarkId markId1;
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit MILLR_D16_Z5_12_37_120_S16_");

        NXOpen.Session.UndoMarkId markId2;
        markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start");

        NXOpen.CAM.Tool            tool1 = (NXOpen.CAM.Tool)workPart.CAMSetup.CAMGroupCollection.FindObject("MILLR_D16_Z5_12_37_120_S16_");
        NXOpen.CAM.MillToolBuilder millToolBuilder1;
        millToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool1);

        theSession.SetUndoMarkName(markId2, "Milling Tool-5 Parameters Dialog");

        millToolBuilder1.HolderLibraryReference = "69871DIN_300480_SK40A70_ER25";

        NXOpen.Point3d scaleAboutPoint1 = new NXOpen.Point3d(-63.376899373644299, 102.03231317600999, 0.0);
        NXOpen.Point3d viewCenter1      = new NXOpen.Point3d(63.376899373645401, -102.03231317600964, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint1, viewCenter1);

        NXOpen.Point3d scaleAboutPoint2 = new NXOpen.Point3d(-81.468531996262811, 132.03520702842695, 0.0);
        NXOpen.Point3d viewCenter2      = new NXOpen.Point3d(81.468531996263877, -132.03520702842664, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint2, viewCenter2);

        NXOpen.Point3d scaleAboutPoint3 = new NXOpen.Point3d(-103.24029485733317, 167.85326850954266, 0.0);
        NXOpen.Point3d viewCenter3      = new NXOpen.Point3d(103.24029485733431, -167.85326850954237, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint3, viewCenter3);

        NXOpen.Point3d scaleAboutPoint4 = new NXOpen.Point3d(-151.8756038292405, 225.61867158447942, 0.0);
        NXOpen.Point3d viewCenter4      = new NXOpen.Point3d(151.87560382924121, -225.61867158447919, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint4, viewCenter4);

        NXOpen.Point3d scaleAboutPoint5 = new NXOpen.Point3d(-115.88196361537399, 180.49493726758354, 0.0);
        NXOpen.Point3d viewCenter5      = new NXOpen.Point3d(115.88196361537494, -180.49493726758325, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint5, viewCenter5);

        NXOpen.Point3d scaleAboutPoint6 = new NXOpen.Point3d(-89.334459223488324, 144.39594981406682, 0.0);
        NXOpen.Point3d viewCenter6      = new NXOpen.Point3d(89.334459223489233, -144.39594981406657, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint6, viewCenter6);

        NXOpen.Point3d scaleAboutPoint7 = new NXOpen.Point3d(-67.871714932058936, 115.51675985125351, 0.0);
        NXOpen.Point3d viewCenter7      = new NXOpen.Point3d(67.871714932059788, -115.51675985125327, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint7, viewCenter7);

        NXOpen.NXObject nXObject1;
        nXObject1 = millToolBuilder1.Commit();

        NXOpen.Session.UndoMarkId markId3;
        markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId3, null);

        NXOpen.Session.UndoMarkId markId4;
        markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId4, null);

        theSession.SetUndoMarkName(markId2, "Milling Tool-5 Parameters");

        millToolBuilder1.Destroy();

        theSession.DeleteUndoMark(markId2, null);

        NXOpen.Session.UndoMarkId markId5;
        markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start");

        NXOpen.CAM.Tool            tool2 = (NXOpen.CAM.Tool)nXObject1;
        NXOpen.CAM.MillToolBuilder millToolBuilder2;
        millToolBuilder2 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool2);

        theSession.SetUndoMarkName(markId5, "Milling Tool-5 Parameters Dialog");

        // ----------------------------------------------
        //   Dialog Begin Milling Tool-5 Parameters
        // ----------------------------------------------
        millToolBuilder2.HolderLibraryReference = "69871DIN_300480_SK40A70_ER32";

        NXOpen.NXObject nXObject2;
        nXObject2 = millToolBuilder2.Commit();

        NXOpen.Session.UndoMarkId markId6;
        markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId6, null);

        NXOpen.Session.UndoMarkId markId7;
        markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId7, null);

        theSession.SetUndoMarkName(markId5, "Milling Tool-5 Parameters");

        millToolBuilder2.Destroy();

        theSession.DeleteUndoMark(markId5, null);

        NXOpen.Session.UndoMarkId markId8;
        markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start");

        NXOpen.CAM.Tool            tool3 = (NXOpen.CAM.Tool)nXObject2;
        NXOpen.CAM.MillToolBuilder millToolBuilder3;
        millToolBuilder3 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool3);

        theSession.SetUndoMarkName(markId8, "Milling Tool-5 Parameters Dialog");

        // ----------------------------------------------
        //   Dialog Begin Milling Tool-5 Parameters
        // ----------------------------------------------
        NXOpen.Point3d scaleAboutPoint8 = new NXOpen.Point3d(-5.3937786700969621, 106.07764717858296, 0.0);
        NXOpen.Point3d viewCenter8      = new NXOpen.Point3d(5.3937786700978423, -106.07764717858277, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint8, viewCenter8);

        NXOpen.Point3d scaleAboutPoint9 = new NXOpen.Point3d(-7.6411864493042421, 132.59705897322871, 0.0);
        NXOpen.Point3d viewCenter9      = new NXOpen.Point3d(7.6411864493050974, -132.59705897322849, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint9, viewCenter9);

        NXOpen.Point3d scaleAboutPoint10 = new NXOpen.Point3d(-9.5514830616303783, 164.62261982693221, 0.0);
        NXOpen.Point3d viewCenter10      = new NXOpen.Point3d(9.5514830616312949, -164.62261982693198, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint10, viewCenter10);

        NXOpen.Point3d scaleAboutPoint11 = new NXOpen.Point3d(-69.529178169224238, 209.99216436967887, 0.0);
        NXOpen.Point3d viewCenter11      = new NXOpen.Point3d(69.529178169225105, -209.99216436967876, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint11, viewCenter11);

        NXOpen.Point3d scaleAboutPoint12 = new NXOpen.Point3d(-55.623342535379315, 167.99373149574299, 0.0);
        NXOpen.Point3d viewCenter12      = new NXOpen.Point3d(55.623342535380232, -167.99373149574294, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint12, viewCenter12);

        NXOpen.Point3d scaleAboutPoint13 = new NXOpen.Point3d(-44.498674028303391, 134.3949851965944, 0.0);
        NXOpen.Point3d viewCenter13      = new NXOpen.Point3d(44.498674028304244, -134.3949851965944, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint13, viewCenter13);

        NXOpen.Session.UndoMarkId markId9;
        markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId9, null);

        NXOpen.Session.UndoMarkId markId10;
        markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        NXOpen.NXObject nXObject3;
        nXObject3 = millToolBuilder3.Commit();

        theSession.DeleteUndoMark(markId10, null);

        theSession.SetUndoMarkName(markId8, "Milling Tool-5 Parameters");

        millToolBuilder3.Destroy();

        theSession.DeleteUndoMark(markId8, null);

        // ----------------------------------------------
        //   Menu: Tools->Journal->Stop Recording
        // ----------------------------------------------
    }
예제 #12
0
    public void CreateBracket(double thickness, double length, double height, double holeradius, double holedistance)
    {
        NXOpen.Point3d point1 = new NXOpen.Point3d(0, 0, 0);
        NXOpen.Point3d point2 = new NXOpen.Point3d(0, 0, height);
        NXOpen.Point3d point3 = new NXOpen.Point3d(0, thickness, height);
        NXOpen.Point3d point4 = new NXOpen.Point3d(0, thickness, thickness);
        NXOpen.Point3d point5 = new NXOpen.Point3d(0, length, thickness);
        NXOpen.Point3d point6 = new NXOpen.Point3d(0, length, 0);

        IBaseCurve[] curves1 = new IBaseCurve[6]
        {
            workPart.Curves.CreateLine(point1, point2),
            workPart.Curves.CreateLine(point2, point3),
            workPart.Curves.CreateLine(point3, point4),
            workPart.Curves.CreateLine(point4, point5),
            workPart.Curves.CreateLine(point5, point6),
            workPart.Curves.CreateLine(point6, point1)
        };

        CreateExtrude(curves1, true, 52.0, new Vector3d(1.0, 0, 0));

        //Left Line
        NXOpen.Point3d point7 = new NXOpen.Point3d(-21.0, 0, height - 8.0);
        NXOpen.Point3d point8 = new NXOpen.Point3d(-21, 0, height - 16.0);
        //Right LIne
        NXOpen.Point3d point9  = new NXOpen.Point3d(-15, 0, height - 16.0);
        NXOpen.Point3d point10 = new NXOpen.Point3d(-15, 0, height - 8.0);
        //Top Arc
        NXOpen.Point3d  Center1 = new NXOpen.Point3d(-18, 0, height - 8.0);
        NXOpen.Vector3d dir1    = new NXOpen.Vector3d(-1.0, 0, 0);
        NXOpen.Vector3d dir2    = new NXOpen.Vector3d(0, 0, -1.0);
        //Bottom Arc
        NXOpen.Point3d Center2 = new NXOpen.Point3d(-18, 0, height - 16.0);

        IBaseCurve[] curves2 = new IBaseCurve[4]
        {
            workPart.Curves.CreateLine(point7, point8),
            workPart.Curves.CreateArc(Center2, dir1, dir2, 3.0, 0, Math.PI),
            workPart.Curves.CreateLine(point9, point10),
            workPart.Curves.CreateArc(Center1, dir1, dir2, 3.0, Math.PI, 2 * Math.PI)
        };

        //Right Side
        //Left Line
        NXOpen.Point3d point11 = new NXOpen.Point3d(21.0, 0, height - 8.0);
        NXOpen.Point3d point12 = new NXOpen.Point3d(21, 0, height - 16.0);
        //Right LIne
        NXOpen.Point3d point13 = new NXOpen.Point3d(15, 0, height - 16.0);
        NXOpen.Point3d point14 = new NXOpen.Point3d(15, 0, height - 8.0);
        //Top Arc
        NXOpen.Point3d Center3 = new NXOpen.Point3d(18, 0, height - 8.0);
        //Bottom Arc
        NXOpen.Point3d Center4 = new NXOpen.Point3d(18, 0, height - 16.0);

        IBaseCurve[] curves3 = new IBaseCurve[4]
        {
            workPart.Curves.CreateLine(point11, point12),
            workPart.Curves.CreateArc(Center4, dir1, dir2, 3.0, 0, Math.PI),
            workPart.Curves.CreateLine(point13, point14),
            workPart.Curves.CreateArc(Center3, dir1, dir2, 3.0, Math.PI, 2 * Math.PI)
        };

        CreateExtrude(curves2, false, 2.0 * thickness, new Vector3d(0, 1, 0));
        CreateExtrude(curves3, false, 2.0 * thickness, new Vector3d(0, 1, 0));

        //EdgeBlend Start
        NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(null);

        NXOpen.ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();

        NXOpen.Edge[]           seedEdges1 = new NXOpen.Edge[2];
        NXOpen.Features.Extrude extrude1   = (NXOpen.Features.Extrude)workPart.Features.ToArray().OfType <NXOpen.Features.Extrude>().First();
        Edge[]         edges         = extrude1.GetBodies()[0].GetEdges();
        NXOpen.Point3d edgeendpoint1 = new NXOpen.Point3d(26, 0, height);
        NXOpen.Point3d edgeendpoint2 = new NXOpen.Point3d(26, thickness, height);
        NXOpen.Point3d edgeendpoint3 = new NXOpen.Point3d(-26, 0, height);
        NXOpen.Point3d edgeendpoint4 = new NXOpen.Point3d(-26, thickness, height);
        Edge           edge1         = null;
        Edge           edge2         = null;

        for (int i = 0; i < edges.Length; i++)
        {
            NXOpen.Point3d endpoint;
            NXOpen.Point3d endpoint2;
            edges[i].GetVertices(out endpoint, out endpoint2);

            if (Math.Abs(edgeendpoint1.X - endpoint.X) < .01 && Math.Abs(edgeendpoint1.Y - endpoint.Y) < .01 && Math.Abs(edgeendpoint1.Z - endpoint.Z) < .01 && Math.Abs(edgeendpoint2.X - endpoint2.X) < .01 && Math.Abs(edgeendpoint2.Y - endpoint2.Y) < .01 && Math.Abs(edgeendpoint2.Z - endpoint2.Z) < .01)
            {
                edge1 = edges[i];
            }
            else if (Math.Abs(edgeendpoint3.X - endpoint.X) < .01 && Math.Abs(edgeendpoint3.Y - endpoint.Y) < .01 && Math.Abs(edgeendpoint3.Z - endpoint.Z) < .01 && Math.Abs(edgeendpoint4.X - endpoint2.X) < .01 && Math.Abs(edgeendpoint4.Y - endpoint2.Y) < .01 && Math.Abs(edgeendpoint4.Z - endpoint2.Z) < .01)
            {
                edge2 = edges[i];
            }

            if (edge1 != null && edge2 != null)
            {
                break;
            }
        }

        seedEdges1[0] = edge1;
        seedEdges1[1] = edge2;

        NXOpen.EdgeMultipleSeedTangentRule edgeMultipleSeedTangentRule1;
        edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);

        NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
        rules1[0] = edgeMultipleSeedTangentRule1;
        scCollector1.ReplaceRules(rules1, false);

        int csIndex1;

        csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, "8");

        edgeBlendBuilder1.CommitFeature();
        edgeBlendBuilder1.Destroy();

        //EdgeBlend End

        //Circle's Extrude
        NXOpen.Point3d  holecenter1 = new NXOpen.Point3d(holedistance / 2, 20, 10);
        NXOpen.Point3d  holecenter2 = new NXOpen.Point3d(-holedistance / 2, 20, 10);
        NXOpen.Vector3d dir3        = new NXOpen.Vector3d(0, -1.0, 0);
        NXOpen.Vector3d dir4        = new NXOpen.Vector3d(1, 0, 0);

        IBaseCurve[] hole1 = new IBaseCurve[1]
        {
            workPart.Curves.CreateArc(holecenter1, dir3, dir4, holeradius, 0, 2 * Math.PI),
        };

        IBaseCurve[] hole2 = new IBaseCurve[1]
        {
            workPart.Curves.CreateArc(holecenter2, dir3, dir4, holeradius, 0, 2 * Math.PI),
        };

        CreateExtrude(hole1, false, 2 * thickness, new Vector3d(0, 0, 1));
        CreateExtrude(hole2, false, 2 * thickness, new Vector3d(0, 0, 1));

        //Big Slot

        //Top Line
        NXOpen.Point3d slotpt1 = new NXOpen.Point3d(-6, 44, 0);
        NXOpen.Point3d slotpt2 = new NXOpen.Point3d(-6, length - 14.0, 0);
        //BOttom Line
        NXOpen.Point3d slotpt4 = new NXOpen.Point3d(6, 44, 0);
        NXOpen.Point3d slotpt3 = new NXOpen.Point3d(6, length - 14.0, 0);
        //Right Arc
        NXOpen.Point3d slotcenter1 = new NXOpen.Point3d(0, 44, 0);
        //Left Arc
        NXOpen.Point3d slotcenter2 = new NXOpen.Point3d(0, length - 14.0, 0);

        IBaseCurve[] slotcurve = new IBaseCurve[4]
        {
            workPart.Curves.CreateLine(slotpt1, slotpt2),
            workPart.Curves.CreateArc(slotcenter2, dir3, dir4, 6.0, Math.PI / 2, 3 * Math.PI / 2),
            workPart.Curves.CreateLine(slotpt3, slotpt4),
            workPart.Curves.CreateArc(slotcenter1, dir3, dir4, 6.0, -Math.PI / 2, Math.PI / 2)
        };

        CreateExtrude(slotcurve, false, 2 * thickness, new Vector3d(0, 0, 1));

        //Curvey Part

        //bottom Arc
        NXOpen.Point3d botarc = new NXOpen.Point3d(26, 44, 0);
        //bottom line
        NXOpen.Point3d botpt1 = new NXOpen.Point3d(14, 44, 0);
        NXOpen.Point3d botpt2 = new NXOpen.Point3d(14, length - 14.0, 0);
        //Big Arc
        NXOpen.Point3d sidearc = new NXOpen.Point3d(0, length - 14.0, 0);
        //Top Line
        NXOpen.Point3d toppt2 = new NXOpen.Point3d(-14, 44, 0);
        NXOpen.Point3d toppt1 = new NXOpen.Point3d(-14, length - 14.0, 0);
        //Right Arc
        NXOpen.Point3d toparc = new NXOpen.Point3d(-26, 44, 0);

        //OUtline
        NXOpen.Point3d out1 = new NXOpen.Point3d(-26, 32, 0);
        NXOpen.Point3d out2 = new NXOpen.Point3d(-28, 32, 0);
        NXOpen.Point3d out3 = new NXOpen.Point3d(-28, length + 10, 0);
        NXOpen.Point3d out4 = new NXOpen.Point3d(28, length + 10, 0);
        NXOpen.Point3d out5 = new NXOpen.Point3d(28, 32, 0);
        NXOpen.Point3d out6 = new NXOpen.Point3d(26, 32, 0);


        IBaseCurve[] bigcutcurve = new IBaseCurve[10]
        {
            workPart.Curves.CreateArc(botarc, dir3, dir4, 12, -Math.PI / 2, 0),
            workPart.Curves.CreateLine(botpt1, botpt2),
            workPart.Curves.CreateArc(sidearc, dir3, dir4, 14, Math.PI / 2, 3 * Math.PI / 2),
            workPart.Curves.CreateLine(toppt1, toppt2),
            workPart.Curves.CreateArc(toparc, dir3, dir4, 12, 0, Math.PI / 2),
            workPart.Curves.CreateLine(out1, out2),
            workPart.Curves.CreateLine(out2, out3),
            workPart.Curves.CreateLine(out3, out4),
            workPart.Curves.CreateLine(out4, out5),
            workPart.Curves.CreateLine(out5, out6)
        };

        CreateExtrude(bigcutcurve, false, 2 * thickness, new Vector3d(0, 0, 1));
    }
예제 #13
0
    public static void Main(string[] args)
    {
        NXOpen.Session           theSession     = NXOpen.Session.GetSession();
        NXOpen.Part              workPart       = theSession.Parts.Work;
        NXOpen.Part              displayPart    = theSession.Parts.Display;
        NXOpen.CAM.PlanarMilling planarMilling1 = (NXOpen.CAM.PlanarMilling)workPart.CAMSetup.CAMOperationCollection.FindObject("PLANAR_MILL");
        theSession.CAMSession.PathDisplay.ShowToolPath(planarMilling1);

        theSession.CAMSession.PathDisplay.HideToolPath(planarMilling1);

        NXOpen.Session.UndoMarkId markId1;
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit MILLR_D16_Z5_12_37_120_S16_");

        NXOpen.Session.UndoMarkId markId2;
        markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start");

        NXOpen.CAM.Tool            tool1 = (NXOpen.CAM.Tool)workPart.CAMSetup.CAMGroupCollection.FindObject("MILLR_D16_Z5_12_37_120_S16_");
        NXOpen.CAM.MillToolBuilder millToolBuilder1;
        millToolBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool1);

        theSession.SetUndoMarkName(markId2, "Milling Tool-5 Parameters Dialog");

        // ----------------------------------------------
        //   Dialog Begin Milling Tool-5 Parameters
        // ----------------------------------------------
        NXOpen.Session.UndoMarkId markId3;
        markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        millToolBuilder1.HolderSectionBuilder.TlHolderOffsetBuilder.Value = 777.0;

        theSession.DeleteUndoMark(markId3, null);

        NXOpen.Session.UndoMarkId markId4;
        markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        NXOpen.NXObject nXObject1;
        nXObject1 = millToolBuilder1.Commit();

        theSession.DeleteUndoMark(markId4, null);

        theSession.SetUndoMarkName(markId2, "Milling Tool-5 Parameters");

        millToolBuilder1.Destroy();

        theSession.DeleteUndoMark(markId2, null);

        NXOpen.Session.UndoMarkId markId5;
        markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit MILLR_D16_Z5_12_37_120_S16_");

        NXOpen.Session.UndoMarkId markId6;
        markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start");

        NXOpen.CAM.Tool            tool2 = (NXOpen.CAM.Tool)nXObject1;
        NXOpen.CAM.MillToolBuilder millToolBuilder2;
        millToolBuilder2 = workPart.CAMSetup.CAMGroupCollection.CreateMillToolBuilder(tool2);

        theSession.SetUndoMarkName(markId6, "Milling Tool-5 Parameters Dialog");

        // ----------------------------------------------
        //   Dialog Begin Milling Tool-5 Parameters
        // ----------------------------------------------
        NXOpen.Point3d scaleAboutPoint1 = new NXOpen.Point3d(-286.70516201357901, 27.560920692940968, 0.0);
        NXOpen.Point3d viewCenter1      = new NXOpen.Point3d(286.7051620135797, -27.560920692940627, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint1, viewCenter1);

        NXOpen.Point3d scaleAboutPoint2 = new NXOpen.Point3d(-229.36412961086322, 22.048736554352818, 0.0);
        NXOpen.Point3d viewCenter2      = new NXOpen.Point3d(229.36412961086378, -22.048736554352505, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint2, viewCenter2);

        NXOpen.Point3d scaleAboutPoint3 = new NXOpen.Point3d(-183.49130368869046, 17.638989243482285, 0.0);
        NXOpen.Point3d viewCenter3      = new NXOpen.Point3d(183.49130368869115, -17.638989243481941, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint3, viewCenter3);

        NXOpen.Point3d scaleAboutPoint4 = new NXOpen.Point3d(-146.7930429509523, 14.477715846598475, 0.0);
        NXOpen.Point3d viewCenter4      = new NXOpen.Point3d(146.79304295095295, -14.47771584659815, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint4, viewCenter4);

        NXOpen.Point3d scaleAboutPoint5 = new NXOpen.Point3d(-117.43443436076178, 11.582172677278839, 0.0);
        NXOpen.Point3d viewCenter5      = new NXOpen.Point3d(117.43443436076245, -11.582172677278479, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint5, viewCenter5);

        NXOpen.Point3d scaleAboutPoint6 = new NXOpen.Point3d(-93.947547488609331, 9.2657381418231157, 0.0);
        NXOpen.Point3d viewCenter6      = new NXOpen.Point3d(93.94754748861007, -9.265738141822764, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint6, viewCenter6);

        NXOpen.Point3d scaleAboutPoint7 = new NXOpen.Point3d(-75.158037990887379, 7.4125905134584906, 0.0);
        NXOpen.Point3d viewCenter7      = new NXOpen.Point3d(75.158037990888076, -7.4125905134581593, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint7, viewCenter7);

        NXOpen.Point3d scaleAboutPoint8 = new NXOpen.Point3d(-60.12643039270985, 5.9300724107668339, 0.0);
        NXOpen.Point3d viewCenter8      = new NXOpen.Point3d(60.126430392710503, -5.9300724107665177, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint8, viewCenter8);

        NXOpen.Point3d scaleAboutPoint9 = new NXOpen.Point3d(-49.061966173127487, 2.9425169430641356, 0.0);
        NXOpen.Point3d viewCenter9      = new NXOpen.Point3d(49.061966173128155, -2.9425169430638092, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint9, viewCenter9);

        NXOpen.Point3d scaleAboutPoint10 = new NXOpen.Point3d(-39.24957293850192, 2.3540135544513348, 0.0);
        NXOpen.Point3d viewCenter10      = new NXOpen.Point3d(39.249572938502602, -2.3540135544510212, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint10, viewCenter10);

        NXOpen.Point3d scaleAboutPoint11 = new NXOpen.Point3d(-31.399658350801484, 1.8832108435610995, 0.0);
        NXOpen.Point3d viewCenter11      = new NXOpen.Point3d(31.399658350802142, -1.883210843560791, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint11, viewCenter11);

        NXOpen.Point3d origin1 = new NXOpen.Point3d(164.84120942379855, -231.96225566314746, 93.442374791060715);
        workPart.ModelingViews.WorkView.SetOrigin(origin1);

        NXOpen.Point3d origin2 = new NXOpen.Point3d(164.84120942379855, -231.96225566314746, 93.442374791060715);
        workPart.ModelingViews.WorkView.SetOrigin(origin2);

        NXOpen.Matrix3x3 rotMatrix1 = new NXOpen.Matrix3x3();
        rotMatrix1.Xx = -0.92455190915842644;
        rotMatrix1.Xy = 0.36837264888254806;
        rotMatrix1.Xz = -0.09749542977373428;
        rotMatrix1.Yx = -0.12480670128190648;
        rotMatrix1.Yy = -0.050994564468317953;
        rotMatrix1.Yz = 0.99086974003136052;
        rotMatrix1.Zx = 0.36003757385395102;
        rotMatrix1.Zy = 0.9282785928534294;
        rotMatrix1.Zz = 0.093122497085394787;
        NXOpen.Point3d translation1 = new NXOpen.Point3d(246.96300992949458, -83.844748234257665, 147.27497989586558);
        workPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix1, translation1, 4.3026858150475196);

        NXOpen.Point3d scaleAboutPoint12 = new NXOpen.Point3d(-27.88689363444497, 0.95313528408813641, 0.0);
        NXOpen.Point3d viewCenter12      = new NXOpen.Point3d(27.886893634445624, -0.9531352840878311, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint12, viewCenter12);

        NXOpen.Point3d scaleAboutPoint13 = new NXOpen.Point3d(-22.260320828377161, 0.81170230644928132, 0.0);
        NXOpen.Point3d viewCenter13      = new NXOpen.Point3d(22.260320828377843, -0.8117023064489669, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint13, viewCenter13);

        NXOpen.Point3d scaleAboutPoint14 = new NXOpen.Point3d(-17.729546136015692, 0.9248486885603705, 0.0);
        NXOpen.Point3d viewCenter14      = new NXOpen.Point3d(17.729546136016374, -0.92484868856005742, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint14, viewCenter14);

        NXOpen.Point3d scaleAboutPoint15 = new NXOpen.Point3d(-14.183636908812508, 1.2436263216385735, 0.0);
        NXOpen.Point3d viewCenter15      = new NXOpen.Point3d(14.183636908813163, -1.2436263216382608, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint15, viewCenter15);

        // ----------------------------------------------
        //   Menu: View->Operation->Fit
        // ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit();

        NXOpen.Point3d scaleAboutPoint16 = new NXOpen.Point3d(15.504435415295911, 219.79817265213524, 0.0);
        NXOpen.Point3d viewCenter16      = new NXOpen.Point3d(-15.504435415295911, -219.79817265213524, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint16, viewCenter16);

        NXOpen.Point3d scaleAboutPoint17 = new NXOpen.Point3d(12.403548332236728, 175.83853812170818, 0.0);
        NXOpen.Point3d viewCenter17      = new NXOpen.Point3d(-12.403548332236529, -175.83853812170818, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint17, viewCenter17);

        NXOpen.Point3d scaleAboutPoint18 = new NXOpen.Point3d(9.9228386657894614, 140.67083049736655, 0.0);
        NXOpen.Point3d viewCenter18      = new NXOpen.Point3d(-9.9228386657891434, -140.67083049736655, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint18, viewCenter18);

        NXOpen.Point3d scaleAboutPoint19 = new NXOpen.Point3d(7.0043567052632767, 114.40449285263009, 0.0);
        NXOpen.Point3d viewCenter19      = new NXOpen.Point3d(-7.0043567052630227, -114.40449285263009, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint19, viewCenter19);

        NXOpen.Point3d scaleAboutPoint20 = new NXOpen.Point3d(2.6149598366315758, 93.764988427788197, 0.0);
        NXOpen.Point3d viewCenter20      = new NXOpen.Point3d(-2.6149598366314741, -93.764988427788239, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint20, viewCenter20);

        NXOpen.Point3d scaleAboutPoint21 = new NXOpen.Point3d(3.2686997957895967, 117.20623553473519, 0.0);
        NXOpen.Point3d viewCenter21      = new NXOpen.Point3d(-3.2686997957893427, -117.20623553473537, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint21, viewCenter21);

        NXOpen.Point3d scaleAboutPoint22 = new NXOpen.Point3d(4.0858747447369961, 146.507794418419, 0.0);
        NXOpen.Point3d viewCenter22      = new NXOpen.Point3d(-4.085874744736679, -146.50779441841922, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint22, viewCenter22);

        NXOpen.Point3d scaleAboutPoint23 = new NXOpen.Point3d(5.1073434309211461, 183.13474302302382, 0.0);
        NXOpen.Point3d viewCenter23      = new NXOpen.Point3d(-5.1073434309210466, -183.13474302302401, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint23, viewCenter23);

        NXOpen.Point3d scaleAboutPoint24 = new NXOpen.Point3d(-4.5601280633219918, 230.7424800041087, 0.0);
        NXOpen.Point3d viewCenter24      = new NXOpen.Point3d(4.5601280633224883, -230.74248000410896, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint24, viewCenter24);

        NXOpen.Point3d scaleAboutPoint25 = new NXOpen.Point3d(-5.7001600791526439, 288.42810000513583, 0.0);
        NXOpen.Point3d viewCenter25      = new NXOpen.Point3d(5.7001600791529539, -288.428100005136, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint25, viewCenter25);

        NXOpen.Point3d scaleAboutPoint26 = new NXOpen.Point3d(-7.125200098940998, 360.53512500641995, 0.0);
        NXOpen.Point3d viewCenter26      = new NXOpen.Point3d(7.1252000989413853, -360.53512500641995, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint26, viewCenter26);

        NXOpen.Point3d scaleAboutPoint27 = new NXOpen.Point3d(-8.9065001236762491, 450.668906258025, 0.0);
        NXOpen.Point3d viewCenter27      = new NXOpen.Point3d(8.9065001236762491, -450.668906258025, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint27, viewCenter27);

        NXOpen.Point3d scaleAboutPoint28 = new NXOpen.Point3d(-69.025375958491892, 469.81788152392915, 0.0);
        NXOpen.Point3d viewCenter28      = new NXOpen.Point3d(69.025375958491892, -469.81788152392915, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint28, viewCenter28);

        NXOpen.Matrix3x3 rotMatrix2 = new NXOpen.Matrix3x3();
        rotMatrix2.Xx = -0.32570673521222537;
        rotMatrix2.Xy = 0.93619419322519726;
        rotMatrix2.Xz = 0.13211947323849185;
        rotMatrix2.Yx = -0.46660733165419815;
        rotMatrix2.Yy = -0.28070137983368343;
        rotMatrix2.Yz = 0.83873972924025531;
        rotMatrix2.Zx = 0.82230938258294473;
        rotMatrix2.Zy = 0.21153526403625911;
        rotMatrix2.Zz = 0.52826140440615954;
        NXOpen.Point3d translation2 = new NXOpen.Point3d(160.31288587598124, 658.78312117697226, 212.07365751642178);
        workPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix2, translation2, 0.074266920131170408);

        NXOpen.Point3d scaleAboutPoint29 = new NXOpen.Point3d(194.16170269614508, 475.60710660431897, 0.0);
        NXOpen.Point3d viewCenter29      = new NXOpen.Point3d(-194.16170269614508, -475.60710660431897, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint29, viewCenter29);

        NXOpen.Point3d scaleAboutPoint30 = new NXOpen.Point3d(242.70212837018136, 594.5088832553987, 0.0);
        NXOpen.Point3d viewCenter30      = new NXOpen.Point3d(-242.70212837018136, -594.5088832553987, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint30, viewCenter30);

        NXOpen.Point3d scaleAboutPoint31 = new NXOpen.Point3d(303.37766046272668, 743.13610406924829, 0.0);
        NXOpen.Point3d viewCenter31      = new NXOpen.Point3d(-303.37766046272668, -743.13610406924829, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint31, viewCenter31);

        NXOpen.Point3d scaleAboutPoint32 = new NXOpen.Point3d(379.22207557840835, 901.08731720007154, 0.0);
        NXOpen.Point3d viewCenter32      = new NXOpen.Point3d(-379.22207557840835, -901.08731720007154, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint32, viewCenter32);

        NXOpen.Point3d scaleAboutPoint33 = new NXOpen.Point3d(465.32984044598311, -152.21069547298509, 0.0);
        NXOpen.Point3d viewCenter33      = new NXOpen.Point3d(-465.32984044598311, 152.21069547298509, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint33, viewCenter33);

        NXOpen.Point3d scaleAboutPoint34 = new NXOpen.Point3d(570.79010802369487, -201.13556187501464, 0.0);
        NXOpen.Point3d viewCenter34      = new NXOpen.Point3d(-570.79010802369487, 201.13556187501686, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint34, viewCenter34);

        NXOpen.Point3d scaleAboutPoint35 = new NXOpen.Point3d(482.45354368669388, 699.89739436238756, 0.0);
        NXOpen.Point3d viewCenter35      = new NXOpen.Point3d(-482.45354368669388, -699.89739436238574, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint35, viewCenter35);

        NXOpen.Point3d scaleAboutPoint36 = new NXOpen.Point3d(385.96283494935358, 559.91791548991068, 0.0);
        NXOpen.Point3d viewCenter36      = new NXOpen.Point3d(-385.96283494935653, -559.91791548990852, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint36, viewCenter36);

        NXOpen.Point3d scaleAboutPoint37 = new NXOpen.Point3d(317.46802198651068, 465.32984044598362, 0.0);
        NXOpen.Point3d viewCenter37      = new NXOpen.Point3d(-317.46802198651307, -465.32984044598186, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint37, viewCenter37);

        NXOpen.Point3d scaleAboutPoint38 = new NXOpen.Point3d(253.97441758920854, 407.05488846489862, 0.0);
        NXOpen.Point3d viewCenter38      = new NXOpen.Point3d(-253.97441758921042, -407.05488846489578, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint38, viewCenter38);

        NXOpen.Point3d scaleAboutPoint39 = new NXOpen.Point3d(203.17953407136687, 381.30953654489662, 0.0);
        NXOpen.Point3d viewCenter39      = new NXOpen.Point3d(-203.17953407136915, -381.309536544894, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint39, viewCenter39);

        millToolBuilder2.HolderSectionBuilder.TlHolderOffsetBuilder.Value = 5.0;

        NXOpen.Point3d scaleAboutPoint40 = new NXOpen.Point3d(-362.93988003981349, 723.6531350487071, 0.0);
        NXOpen.Point3d viewCenter40      = new NXOpen.Point3d(362.93988003981076, -723.65313504870437, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint40, viewCenter40);

        NXOpen.Point3d scaleAboutPoint41 = new NXOpen.Point3d(-347.35350482338032, 610.98590848420099, 0.0);
        NXOpen.Point3d viewCenter41      = new NXOpen.Point3d(347.35350482337736, -610.98590848419792, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint41, viewCenter41);

        NXOpen.Point3d scaleAboutPoint42 = new NXOpen.Point3d(-277.88280385870468, 491.63880682693821, 0.0);
        NXOpen.Point3d viewCenter42      = new NXOpen.Point3d(277.88280385870161, -491.63880682693451, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint42, viewCenter42);

        NXOpen.Point3d scaleAboutPoint43 = new NXOpen.Point3d(-222.30624308696406, 393.3110454615508, 0.0);
        NXOpen.Point3d viewCenter43      = new NXOpen.Point3d(222.30624308696093, -393.31104546154711, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint43, viewCenter43);

        NXOpen.Point3d scaleAboutPoint44 = new NXOpen.Point3d(382.1387317064079, 413.1476025370028, 0.0);
        NXOpen.Point3d viewCenter44      = new NXOpen.Point3d(-382.13873170641091, -413.1476025369991, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint44, viewCenter44);

        NXOpen.Point3d scaleAboutPoint45 = new NXOpen.Point3d(466.27309447470458, 516.43450317125303, 0.0);
        NXOpen.Point3d viewCenter45      = new NXOpen.Point3d(-466.27309447470719, -516.43450317124928, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint45, viewCenter45);

        NXOpen.Point3d scaleAboutPoint46 = new NXOpen.Point3d(579.99128805380462, 645.54312896406589, 0.0);
        NXOpen.Point3d viewCenter46      = new NXOpen.Point3d(-579.99128805380735, -645.54312896406225, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint46, viewCenter46);

        NXOpen.Point3d origin3 = new NXOpen.Point3d(-456.82871085494554, 659.5905676803327, 45.534677646621525);
        workPart.ModelingViews.WorkView.SetOrigin(origin3);

        NXOpen.Point3d origin4 = new NXOpen.Point3d(-456.82871085494554, 659.5905676803327, 45.534677646621525);
        workPart.ModelingViews.WorkView.SetOrigin(origin4);

        NXOpen.Point3d scaleAboutPoint47 = new NXOpen.Point3d(379.41690526861242, 439.98110610961515, 0.0);
        NXOpen.Point3d viewCenter47      = new NXOpen.Point3d(-379.41690526861532, -439.98110610961106, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint47, viewCenter47);

        NXOpen.Point3d scaleAboutPoint48 = new NXOpen.Point3d(465.36463146208962, 549.97638263701833, 0.0);
        NXOpen.Point3d viewCenter48      = new NXOpen.Point3d(-465.36463146209201, -549.97638263701413, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint48, viewCenter48);

        NXOpen.Point3d scaleAboutPoint49 = new NXOpen.Point3d(548.30641386382592, 681.90391571897487, 0.0);
        NXOpen.Point3d viewCenter49      = new NXOpen.Point3d(-548.30641386382933, -681.90391571897032, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint49, viewCenter49);

        NXOpen.Point3d scaleAboutPoint50 = new NXOpen.Point3d(615.8009851135597, 831.50528498385142, 0.0);
        NXOpen.Point3d viewCenter50      = new NXOpen.Point3d(-615.80098511356357, -831.50528498384665, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint50, viewCenter50);

        // ----------------------------------------------
        //   Menu: View->Operation->Fit
        // ----------------------------------------------
        workPart.ModelingViews.WorkView.Fit();

        NXOpen.Matrix3x3 rotMatrix3 = new NXOpen.Matrix3x3();
        rotMatrix3.Xx = -0.074067505804252642;
        rotMatrix3.Xy = 0.99277609926014787;
        rotMatrix3.Xz = 0.094390790449827497;
        rotMatrix3.Yx = -0.0020149135722141304;
        rotMatrix3.Yy = -0.094799559997341881;
        rotMatrix3.Yz = 0.99549434129361458;
        rotMatrix3.Zx = 0.99725119438746967;
        rotMatrix3.Zy = 0.073543593617096698;
        rotMatrix3.Zz = 0.0090219249969129348;
        NXOpen.Point3d translation3 = new NXOpen.Point3d(3.1589136400735374, -105.14889998754266, 33.616845100090721);
        workPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix3, translation3, 0.70100925726828234);

        // ----------------------------------------------
        //   Menu: Snap View
        // ----------------------------------------------
        workPart.ModelingViews.WorkView.SnapToClosestCannedOrientation();

        NXOpen.Point3d scaleAboutPoint51 = new NXOpen.Point3d(-16.795724466199619, 122.4766873995907, 0.0);
        NXOpen.Point3d viewCenter51      = new NXOpen.Point3d(16.795724466199619, -122.4766873995907, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint51, viewCenter51);

        NXOpen.Point3d scaleAboutPoint52 = new NXOpen.Point3d(-20.994655582749555, 152.15227922329743, 0.0);
        NXOpen.Point3d viewCenter52      = new NXOpen.Point3d(20.994655582749555, -152.15227922329734, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint52, viewCenter52);

        NXOpen.Point3d scaleAboutPoint53 = new NXOpen.Point3d(-26.243319478436941, 188.42113648001362, 0.0);
        NXOpen.Point3d viewCenter53      = new NXOpen.Point3d(26.243319478436941, -188.42113648001362, 0.0);
        workPart.ModelingViews.WorkView.ZoomAboutPoint(0.80000000000000004, scaleAboutPoint53, viewCenter53);

        NXOpen.Session.UndoMarkId markId7;
        markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        theSession.DeleteUndoMark(markId7, null);

        NXOpen.Session.UndoMarkId markId8;
        markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Milling Tool-5 Parameters");

        NXOpen.NXObject nXObject2;
        nXObject2 = millToolBuilder2.Commit();

        theSession.DeleteUndoMark(markId8, null);

        theSession.SetUndoMarkName(markId6, "Milling Tool-5 Parameters");

        millToolBuilder2.Destroy();

        theSession.DeleteUndoMark(markId6, null);

        // ----------------------------------------------
        //   Menu: Tools->Journal->Stop Recording
        // ----------------------------------------------
    }
예제 #14
0
        static void Main(string[] args)
        {
            //Get the NX Open API
            Session theNXAutomationSession = Session.GetSession();
            // Get the NX Open API
            //NXOpen.UI theUI = UI.GetUI();
            //Get the UF Session using NX Open UF API
            UFSession theNXOpenNetSession = UFSession.GetUFSession();

            try
            {
                //Declartions
                string name;

                // Intilize the NX Open UF Session, This will not needed once UF
                // will get intilized in Session.
                //theNXOpenNetSession.UF.Initialize();

                //Create new part using NX Open UF API
                //string part_name = "CreateLine2";
                //int units =2;
                //theNXOpenNetSession.Part.New(part_name, units, out part);

                //Create New Part file using NX Open API
                NXOpen.Part myPart = theNXAutomationSession.Parts.NewDisplay("InteropNXOpenWithUFWrap", NXOpen.Part.Units.Millimeters);
                NXOpen.Tag  part   = myPart.Tag;
                //Query the part name using NX Open API
                theNXOpenNetSession.Part.AskPartName(part, out name);

                // Create Line using NX Open APIs
                NXOpen.Point3d point3d1 = new Point3d(-2.45197396411307, 3.58206319143819, 0);
                NXOpen.Point3d point3d2 = new Point3d(5.32514590979158, -1.0012853802839, 0);
                NXOpen.Line    line1    = theNXAutomationSession.Parts.Work.Curves.CreateLine(point3d1, point3d2);

                //Ask line data using NX Open UF API
                NXOpen.UF.UFCurve.Line line_coords;
                theNXOpenNetSession.Curve.AskLineData(line1.Tag, out line_coords);

                // Create Arc using NXOpen UF API
                NXOpen.Tag            arc, wcs;
                NXOpen.UF.UFCurve.Arc arc_coords = new NXOpen.UF.UFCurve.Arc();

                // Fill out the data structure
                arc_coords.start_angle   = 0.0;
                arc_coords.end_angle     = 3.0;
                arc_coords.arc_center    = new double[3];
                arc_coords.arc_center[0] = 0.0;
                arc_coords.arc_center[1] = 0.0;
                arc_coords.arc_center[2] = 1.0;
                arc_coords.radius        = 2.0;

                // Create a ARC using NXOpen UF API
                theNXOpenNetSession.Csys.AskWcs(out wcs);
                theNXOpenNetSession.Csys.AskMatrixOfObject(wcs, out arc_coords.matrix_tag);
                theNXOpenNetSession.Curve.CreateArc(ref arc_coords, out arc);

                // Create NX Open Arc Object using NXOpen UF arc Tag
                Arc NxArc = (Arc)NXOpen.Utilities.NXObjectManager.Get(arc);

                //Get the Arc parameters using NX Open APIs
                double         start_angle = NxArc.StartAngle;
                double         end_angle   = NxArc.EndAngle;
                NXOpen.Point3d arc_center  = NxArc.CenterPoint;

                // Save the Part using NXOpen UF API
                theNXOpenNetSession.Part.Save();
            }
            catch (NXException e)
            {
                Console.WriteLine("Exception is: {0}", e.Message);
            }
        }
예제 #15
0
    public static void Main(string[] args)
    {
        NXOpen.Session theSession = NXOpen.Session.GetSession();
        // ----------------------------------------------
        //   Menu: File->New...
        // ----------------------------------------------

        //Variable Declaration
        double a = double.Parse(args[0]);
        double G = 1.618;
        double b = G * a;
        double L = 10;
        double t = double.Parse(args[1]);


        NXOpen.FileNew fileNew1;
        fileNew1 = theSession.Parts.FileNew();

        fileNew1.TemplateFileName = "model-plain-1-mm-template.prt";

        fileNew1.UseBlankTemplate = false;

        fileNew1.ApplicationName = "ModelTemplate";

        fileNew1.Units = NXOpen.Part.Units.Millimeters;

        fileNew1.RelationType = "";

        fileNew1.UsesMasterModel = "No";

        fileNew1.TemplateType = NXOpen.FileNewTemplateType.Item;

        fileNew1.TemplatePresentationName = "Model";

        fileNew1.ItemType = "";

        fileNew1.Specialization = "";

        fileNew1.SetCanCreateAltrep(false);

        fileNew1.NewFileName = "J:\\ME 578 Systems\\Midterm\\MidtermProject\\GoldBeam.prt";

        fileNew1.MasterFileName = "";

        fileNew1.MakeDisplayedPart = true;

        NXOpen.NXObject nXObject1;
        nXObject1 = fileNew1.Commit();

        NXOpen.Part workPart    = theSession.Parts.Work;
        NXOpen.Part displayPart = theSession.Parts.Display;

        fileNew1.Destroy();

        theSession.ApplicationSwitchImmediate("UG_APP_MODELING");

        // ----------------------------------------------
        //   Menu: Insert->Sketch...
        // ----------------------------------------------

        NXOpen.Sketch nullNXOpen_Sketch = null;
        NXOpen.SketchInPlaceBuilder sketchInPlaceBuilder1;
        sketchInPlaceBuilder1 = workPart.Sketches.CreateNewSketchInPlaceBuilder(nullNXOpen_Sketch);

        NXOpen.Unit       unit1 = (NXOpen.Unit)workPart.UnitCollection.FindObject("MilliMeter");
        NXOpen.Expression expression1;
        expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

        NXOpen.Expression expression2;
        expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1);

        NXOpen.SketchAlongPathBuilder sketchAlongPathBuilder1;
        sketchAlongPathBuilder1 = workPart.Sketches.CreateSketchAlongPathBuilder(nullNXOpen_Sketch);

        sketchAlongPathBuilder1.PlaneLocation.Expression.RightHandSide = "0";

        NXOpen.DatumPlane datumPlane1 = (NXOpen.DatumPlane)workPart.Datums.FindObject("DATUM_CSYS(0) YZ plane");
        NXOpen.Point3d    point1      = new NXOpen.Point3d(0, 0, 0);
        sketchInPlaceBuilder1.PlaneOrFace.SetValue(datumPlane1, workPart.ModelingViews.WorkView, point1);

        NXOpen.Features.DatumCsys datumCsys1 = (NXOpen.Features.DatumCsys)workPart.Features.FindObject("DATUM_CSYS(0)");
        NXOpen.Point point2 = (NXOpen.Point)datumCsys1.FindObject("POINT 1");
        sketchInPlaceBuilder1.SketchOrigin = point2;

        sketchInPlaceBuilder1.PlaneOrFace.Value = null;

        sketchInPlaceBuilder1.PlaneOrFace.Value = datumPlane1;

        NXOpen.DatumAxis datumAxis1 = (NXOpen.DatumAxis)workPart.Datums.FindObject("DATUM_CSYS(0) X axis");
        sketchInPlaceBuilder1.Axis.Value = datumAxis1;

        theSession.Preferences.Sketch.CreateInferredConstraints = true;

        theSession.Preferences.Sketch.ContinuousAutoDimensioning = true;

        theSession.Preferences.Sketch.DimensionLabel = NXOpen.Preferences.SketchPreferences.DimensionLabelType.Expression;

        theSession.Preferences.Sketch.TextSizeFixed = true;

        theSession.Preferences.Sketch.FixedTextSize = 3.0;

        theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0;

        theSession.Preferences.Sketch.DisplayObjectColor = false;

        theSession.Preferences.Sketch.DisplayObjectName = true;

        NXOpen.NXObject nXObject2;
        nXObject2 = sketchInPlaceBuilder1.Commit();

        NXOpen.Sketch           sketch1 = (NXOpen.Sketch)nXObject2;
        NXOpen.Features.Feature feature1;
        feature1 = sketch1.Feature;

        sketch1.Activate(NXOpen.Sketch.ViewReorient.True);

        sketchInPlaceBuilder1.Destroy();

        sketchAlongPathBuilder1.Destroy();

        try
        {
            // Expression is still in use.
            workPart.Expressions.Delete(expression2);
        }
        catch (NXException ex)
        {
            ex.AssertErrorCode(1050029);
        }

        try
        {
            // Expression is still in use.
            workPart.Expressions.Delete(expression1);
        }
        catch (NXException ex)
        {
            ex.AssertErrorCode(1050029);
        }

        // ----------------------------------------------
        //   Menu: Insert->Sketch Curve->Line...
        // ----------------------------------------------
        NXOpen.Point3d startPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
        NXOpen.Point3d endPoint1   = new NXOpen.Point3d(0, b, 0.0);
        NXOpen.Line    line1;
        line1 = workPart.Curves.CreateLine(startPoint1, endPoint1);

        theSession.ActiveSketch.AddGeometry(line1, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        //

        NXOpen.Point3d startPoint2 = new NXOpen.Point3d(0.0, b, 0.0);
        NXOpen.Point3d endPoint2   = new NXOpen.Point3d(L, a, 0.0);
        NXOpen.Line    line2;
        line2 = workPart.Curves.CreateLine(startPoint2, endPoint2);

        theSession.ActiveSketch.AddGeometry(line2, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------

        NXOpen.Point3d startPoint3 = new NXOpen.Point3d(L, a, 0.0);
        NXOpen.Point3d endPoint3   = new NXOpen.Point3d(L, 0.0, 0.0);
        NXOpen.Line    line3;
        line3 = workPart.Curves.CreateLine(startPoint3, endPoint3);

        theSession.ActiveSketch.AddGeometry(line3, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        NXOpen.Point3d startPoint4 = new NXOpen.Point3d(L, 0.0, 0.0);
        NXOpen.Point3d endPoint4   = new NXOpen.Point3d(0.0, 0.0, 0.0);
        NXOpen.Line    line4;
        line4 = workPart.Curves.CreateLine(startPoint4, endPoint4);

        theSession.ActiveSketch.AddGeometry(line4, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = false;

        theSession.ActiveSketch.Update();

        theSession.Preferences.Sketch.AutoDimensionsToArcCenter = true;

        // ----------------------------------------------
        //   Dialog Begin Line
        // ----------------------------------------------
        // ----------------------------------------------
        //   Menu: File->Finish Sketch
        // ----------------------------------------------
        theSession.ActiveSketch.Deactivate(NXOpen.Sketch.ViewReorient.False, NXOpen.Sketch.UpdateLevel.Model);

        // ----------------------------------------------
        //   Menu: Insert->Design Feature->Extrude...
        // ----------------------------------------------

        NXOpen.Features.Feature nullNXOpen_Features_Feature = null;

        if (!workPart.Preferences.Modeling.GetHistoryMode())
        {
            throw new Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode.");
        }

        NXOpen.Features.ExtrudeBuilder extrudeBuilder1;
        extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature);

        NXOpen.Section section1;
        section1 = workPart.Sections.CreateSection(0.0095, 0.01, 0.5);

        extrudeBuilder1.Section = section1;

        extrudeBuilder1.AllowSelfIntersectingSection(true);

        NXOpen.Unit unit2;
        unit2 = extrudeBuilder1.Draft.FrontDraftAngle.Units;

        NXOpen.Expression expression7;
        expression7 = workPart.Expressions.CreateSystemExpressionWithUnits("2.00", unit2);

        extrudeBuilder1.DistanceTolerance = 0.01;

        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

        NXOpen.Body[] targetBodies1   = new NXOpen.Body[1];
        NXOpen.Body   nullNXOpen_Body = null;
        targetBodies1[0] = nullNXOpen_Body;
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1);

        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0";

        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = t.ToString();

        extrudeBuilder1.Offset.StartOffset.RightHandSide = "0";

        extrudeBuilder1.Offset.EndOffset.RightHandSide = "5";


        NXOpen.GeometricUtilities.SmartVolumeProfileBuilder smartVolumeProfileBuilder1;
        smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile;

        smartVolumeProfileBuilder1.OpenProfileSmartVolumeOption = false;

        smartVolumeProfileBuilder1.CloseProfileRule = NXOpen.GeometricUtilities.SmartVolumeProfileBuilder.CloseProfileRuleType.Fci;

        section1.DistanceTolerance = 0.01;

        section1.ChainingTolerance = 0.0095;

        section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);

        NXOpen.Features.Feature[]     features1      = new NXOpen.Features.Feature[1];
        NXOpen.Features.SketchFeature sketchFeature1 = (NXOpen.Features.SketchFeature)feature1;
        features1[0] = sketchFeature1;
        NXOpen.CurveFeatureRule curveFeatureRule1;
        curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features1);

        section1.AllowSelfIntersection(true);

        NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1];
        rules1[0] = curveFeatureRule1;
        NXOpen.Point3d helpPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
        section1.AddToSection(rules1, null, null, null, helpPoint1, NXOpen.Section.Mode.Create, false);

        NXOpen.Direction direction1;
        direction1 = workPart.Directions.CreateDirection(sketch1, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.WithinModeling);

        extrudeBuilder1.Direction = direction1;

        extrudeBuilder1.ParentFeatureInternal = false;

        NXOpen.Features.Feature feature2;
        feature2 = extrudeBuilder1.CommitFeature();

        NXOpen.Expression expression8 = extrudeBuilder1.Limits.StartExtend.Value;
        NXOpen.Expression expression9 = extrudeBuilder1.Limits.EndExtend.Value;
        extrudeBuilder1.Destroy();

        workPart.Expressions.Delete(expression7);

        // ----------------------------------------------
        //   Menu: Tools->Journal->Stop Recording
        // ----------------------------------------------
        // ----------------------------------------------
        //   Menu: File->Export->IGES...
        // ----------------------------------------------

        NXOpen.IgesCreator igesCreator1;
        igesCreator1 = theSession.DexManager.CreateIgesCreator();

        igesCreator1.ExportModelData = true;

        igesCreator1.ExportDrawings = true;

        igesCreator1.MapTabCylToBSurf = true;

        igesCreator1.BcurveTol = 0.0508;

        igesCreator1.IdenticalPointResolution = 0.001;

        igesCreator1.MaxThreeDMdlSpace = 10000.0;

        igesCreator1.ObjectTypes.Curves = true;

        igesCreator1.ObjectTypes.Surfaces = true;

        igesCreator1.ObjectTypes.Annotations = true;

        igesCreator1.ObjectTypes.Structures = true;

        igesCreator1.ObjectTypes.Solids = true;

        igesCreator1.SettingsFile = "C:\\Program Files\\Siemens\\NX 10.0\\iges\\igesexport.def";

        igesCreator1.MaxLineThickness = 2.0;

        igesCreator1.SysDefmaxThreeDMdlSpace = true;

        igesCreator1.SysDefidenticalPointResolution = true;

        igesCreator1.InputFile = "J:\\ME 578 Systems\\Midterm\\MidtermProject\\GoldBeam.igs";

        igesCreator1.OutputFile = "J:\\ME 578 Systems\\Midterm\\MidtermProject\\GoldBeam.igs";

        igesCreator1.FileSaveFlag = false;

        igesCreator1.LayerMask = "1-256";

        igesCreator1.DrawingList = "";

        NXOpen.TaggedObject[] objects1 = new NXOpen.TaggedObject[0];
        igesCreator1.SetDrawingArray(objects1);

        NXOpen.NXObject nXObject20;
        nXObject20 = igesCreator1.Commit();

        igesCreator1.Destroy();

        while (!System.IO.File.Exists("J:\\ME 578 Systems\\Midterm\\MidtermProject\\GoldBeam.igs"))
        {
            System.Threading.Thread.Sleep(10);
        }
    }
예제 #16
0
    Snap.Geom.Transform GetTransform(Snap.Position elecOrgin)
    {
        var transForm = Snap.Geom.Transform.CreateTranslation();

        bool isRotation = true;
        bool isMove     = true;

        if (enum01.SelectedItem == "平移")
        {
            isRotation = toggleMoveRotation.Value;
        }
        else
        {
            isMove = toggleRotationMove.Value;
        }

        if (isRotation)
        {
            NXOpen.Point3d point = Snap.Globals.Wcs.Origin;
            if (enumRotation.SelectedItem == "指定点")
            {
                point = pointAxis.Position;
            }
            else if (enumRotation.SelectedItem == "电极原点")
            {
                point = elecOrgin;
            }
            transForm = Snap.Geom.Transform.Composition(transForm, Snap.Geom.Transform.CreateRotation(point, vector0.Direction, expressionAngle.Value));
        }

        if (isMove)
        {
            double x = 0;
            double y = 0;
            double z = 0;
            if (enum0.SelectedItem == "点对点")
            {
                Snap.Position startPoint = pointStart.Position;
                Snap.Position endPoint   = pointEnd.Position;
                var           vector     = endPoint - startPoint;
                x = vector.X;
                y = vector.Y;
                z = vector.Z;
            }
            else if (enum0.SelectedItem == "轴")
            {
                var distance = expressionDistance.Value;


                switch (enumSelectAxis.SelectedItem)
                {
                case "X":
                {
                    x = distance;
                    break;
                }

                case "Y":
                {
                    y = distance;
                    break;
                }

                default:      //Z
                {
                    z = distance;
                    break;
                }
                }
            }
            else //增量XYZ
            {
                x = expressionDistanceX.Value;
                y = expressionDistanceY.Value;
                z = expressionDistanceZ.Value;
            }
            transForm = Snap.Geom.Transform.Composition(transForm, Snap.Geom.Transform.CreateTranslation(new Snap.Vector(x, y, z)));
        }

        return(transForm);
    }