コード例 #1
0
ファイル: Position.cs プロジェクト: suifengsigan/TEST_1
 public Position(Snap.NX.Point pt)
 {
     NXOpen.Point nXOpenPoint = pt.NXOpenPoint;
     this.X = nXOpenPoint.Coordinates.X;
     this.Y = nXOpenPoint.Coordinates.Y;
     this.Z = nXOpenPoint.Coordinates.Z;
 }
コード例 #2
0
        internal static Snap.NX.Revolve CreateRevolve(Snap.NX.ICurve[] icurves, Position axisPoint, Vector axisVector, Snap.Number[] extents, bool offset, Snap.Number[] offsetValues, bool createSheet)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.RevolveBuilder featureBuilder = workPart.Features.CreateRevolveBuilder(null);
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            Snap.NX.Section section = Snap.NX.Section.CreateSection(icurves);
            featureBuilder.Section = (NXOpen.Section)section;
            section.NXOpenSection.DistanceTolerance = Globals.DistanceTolerance;
            section.NXOpenSection.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.BooleanOperation.Type    = BooleanOperation.BooleanType.Create;
            if (createSheet)
            {
                featureBuilder.FeatureOptions.BodyType = FeatureOptions.BodyStyle.Sheet;
            }
            featureBuilder.Limits.StartExtend.Value.RightHandSide = extents[0].ToString();
            featureBuilder.Limits.EndExtend.Value.RightHandSide   = extents[1].ToString();
            featureBuilder.Offset.Option = NXOpen.GeometricUtilities.Type.NoOffset;
            if (offset)
            {
                featureBuilder.Offset.Option = NXOpen.GeometricUtilities.Type.NonsymmetricOffset;
                featureBuilder.Offset.StartOffset.RightHandSide = offsetValues[0].ToString();
                featureBuilder.Offset.EndOffset.RightHandSide   = offsetValues[1].ToString();
            }
            Direction direction = workPart.Directions.CreateDirection((Point3d)axisPoint, (Vector3d)axisVector, SmartObject.UpdateOption.WithinModeling);

            NXOpen.Point point = null;
            NXOpen.Axis  axis  = workPart.Axes.CreateAxis(point, direction, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.Axis = axis;
            NXOpen.Features.Revolve revolve = (NXOpen.Features.Revolve)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.Revolve(revolve));
        }
コード例 #3
0
        internal static NXOpen.Point CreatePointInvisible(double x, double y, double z)
        {
            NXOpen.Part workPart    = (NXOpen.Part)Globals.WorkPart;
            Point3d     coordinates = new Point3d(x, y, z);

            NXOpen.Point point = workPart.Points.CreatePoint(coordinates);
            point.SetVisibility(SmartObject.VisibilityOption.Invisible);
            return(point);
        }
コード例 #4
0
 public static Snap.NX.Point Wrap(Tag nxopenPointTag)
 {
     if (nxopenPointTag == Tag.Null)
     {
         throw new ArgumentException("Input tag is NXOpen.Tag.Null");
     }
     NXOpen.Point objectFromTag = Snap.NX.NXObject.GetObjectFromTag(nxopenPointTag) as NXOpen.Point;
     if (objectFromTag == null)
     {
         throw new ArgumentException("Input tag doesn't belong to an NXOpen.Point object");
     }
     return(objectFromTag);
 }
コード例 #5
0
ファイル: Section.cs プロジェクト: suifengsigan/TEST_1
        internal static SelectionIntentRule[] CreateSelectionIntentRule(params Snap.NX.Point[] points)
        {
            if (points == null)
            {
                return(null);
            }
            NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
            for (int i = 0; i < pointArray.Length; i++)
            {
                pointArray[i] = (NXOpen.Point)points[i];
            }
            CurveDumbRule rule = Globals.NXOpenWorkPart.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);

            return(new SelectionIntentRule[] { rule });
        }
コード例 #6
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.Face face)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] ruleArray = new SelectionIntentRule[] { rule };
                Point3d helpPoint = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(ruleArray, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            ScCollector collector = work.ScCollectors.CreateCollector();

            NXOpen.Face[] faces = new NXOpen.Face[] { face };
            FaceDumbRule  rule2 = work.ScRuleFactory.CreateRuleFaceDumb(faces);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule2 };
            collector.ReplaceRules(rules, false);
            featureBuilder.FaceToProjectTo.Add(collector);
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
コード例 #7
0
ファイル: ProjectCurve.cs プロジェクト: suifengsigan/TEST_1
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.DatumPlane datumPlane, Snap.NX.Curve[] curves, Snap.NX.Point[] points)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            //featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
                Point3d helpPoint           = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(rules, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            Position origin = datumPlane.Origin;
            Vector   normal = datumPlane.Normal;

            NXOpen.Plane plane = Globals.NXOpenWorkPart.Planes.CreatePlane((Point3d)origin, (Vector3d)normal, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.PlaneToProjectTo = plane;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
コード例 #8
0
ファイル: PartInformationDlg.cs プロジェクト: chiumimy/cax
        public static bool InsertNote(string text, Point3d textLocation, string FontSize)
        {
            try
            {
                Session theSession  = Session.GetSession();
                Part    workPart    = theSession.Parts.Work;
                Part    displayPart = theSession.Parts.Display;
                // ----------------------------------------------
                //   Menu: Insert->Annotation->Note...
                // ----------------------------------------------
                NXOpen.Session.UndoMarkId markId1;
                markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");
                NXOpen.Annotations.SimpleDraftingAid   nullAnnotations_SimpleDraftingAid = null;
                NXOpen.Annotations.DraftingNoteBuilder draftingNoteBuilder1;
                draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid);
                draftingNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane;
                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(false);
                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                draftingNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

                //text文字
                string[] text1 = new string[1];
                //text1[0] = "<C2>" + text + "<C>";
                text1[0] = text;
                draftingNoteBuilder1.Text.TextBlock.SetText(text1);

                draftingNoteBuilder1.Style.LetteringStyle.GeneralTextSize = Convert.ToDouble(FontSize);

                theSession.SetUndoMarkName(markId1, "Note Dialog");
                draftingNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane;
                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                //NXOpen.Annotations.LeaderData leaderData1;
                //leaderData1 = workPart.Annotations.CreateLeaderData();
                //leaderData1.StubSize = 5.0;
                //leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;
                //draftingNoteBuilder1.Leader.Leaders.Append(leaderData1);
                //leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;
                double symbolscale1;
                symbolscale1 = draftingNoteBuilder1.Text.TextBlock.SymbolScale;
                double symbolaspectratio1;
                symbolaspectratio1 = draftingNoteBuilder1.Text.TextBlock.SymbolAspectRatio;
                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
                assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
                NXOpen.View nullView = null;
                assocOrigin1.View           = nullView;
                assocOrigin1.ViewOfGeometry = nullView;
                NXOpen.Point nullPoint = null;
                assocOrigin1.PointOnGeometry         = nullPoint;
                assocOrigin1.VertAnnotation          = null;
                assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
                assocOrigin1.HorizAnnotation         = null;
                assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
                assocOrigin1.AlignedAnnotation       = null;
                assocOrigin1.DimensionLine           = 0;
                assocOrigin1.AssociatedView          = nullView;
                assocOrigin1.AssociatedPoint         = nullPoint;
                assocOrigin1.OffsetAnnotation        = null;
                assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
                assocOrigin1.XOffsetFactor           = 0.0;
                assocOrigin1.YOffsetFactor           = 0.0;
                assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
                draftingNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

                //text擺放位置
                draftingNoteBuilder1.Origin.Origin.SetValue(null, nullView, textLocation);

                draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
                NXOpen.Session.UndoMarkId markId2;
                markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Note");
                NXObject nXObject1;
                nXObject1 = draftingNoteBuilder1.Commit();
                theSession.DeleteUndoMark(markId2, null);
                theSession.SetUndoMarkName(markId1, "Note");
                theSession.SetUndoMarkVisibility(markId1, null, NXOpen.Session.MarkVisibility.Visible);
                draftingNoteBuilder1.Destroy();


                // ----------------------------------------------
                //   Menu: Tools->Journal->Stop Recording
                // ----------------------------------------------
            }
            catch (System.Exception ex)
            {
                UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
                return(false);
            }
            return(true);
        }
コード例 #9
0
 internal Point(NXOpen.Point pt) : base(pt)
 {
     this.NXOpenPoint = pt;
 }
コード例 #10
0
    void Perform(bool isHighlighted = false)
    {
        var workPart  = theSession.Parts.Work;
        var body      = selection0.SelectedObjects.FirstOrDefault() as Snap.NX.Body;
        var jiajuBody = selectionJiaju.SelectedObjects.FirstOrDefault() as Snap.NX.Body;

        tempObjs.ForEach(u => {
            Snap.NX.NXObject snapU = u;
            snapU.Delete();
        });
        tempObjs.Clear();

        if (body != null)
        {
            Snap.NX.Body snapBody = body;
            //电极原点
            var tempElecOrigin = SnapEx.Helper.GetElecMidPosition(workPart, body);
            if (tempElecOrigin == null)
            {
                theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "该电极未发现基准点!");
                return;
            }
            var elecOrgin = (Snap.Position)tempElecOrigin;


            if (isHighlighted)
            {
                SnapEx.Create.DisplayModification(tempObjs);
            }

            bool isPatter = false;
            if (enum01.SelectedItem == "平移")
            {
                isPatter = toggleMovePatter.Value;
            }
            else
            {
                isPatter = toggleRotationPatter.Value;
            }
            int sum = 0;

            if (isPatter)
            {
                sum = (int)(expressionPatterSum.Value < 0?0:expressionPatterSum.Value);
            }

            double distance = expressionPatterDistance.Value;
            var    vector   = Snap.Vector.Unit(vectorPatter.Direction);

            if (body.NXOpenBody.OwningComponent != null && snapBody.Prototype != null)
            {
                var snapComponent = snapBody.OwningComponent;;
                NXOpen.Assemblies.Component component = snapComponent;


                var transForm = GetTransform(elecOrgin);

                for (int i = 0; i < sum + 1; i++)
                {
                    Snap.NX.Component newComponent = workPart.ComponentAssembly.CopyComponents(new List <NXOpen.Assemblies.Component> {
                        component
                    }.ToArray()).First();
                    newComponent.Prototype.Bodies.First().SetDateTimeAttribute(EACT_POSITIONING_DATE, DateTime.Now);
                    tempObjs.Add(newComponent);

                    //平移旋转
                    var       trans  = transForm.Matrix;
                    Matrix3x3 matrix = new Matrix3x3();
                    matrix.Xx = trans[0]; matrix.Xy = trans[4]; matrix.Xz = trans[8];
                    matrix.Yx = trans[1]; matrix.Yy = trans[5]; matrix.Yz = trans[9];
                    matrix.Zx = trans[2]; matrix.Zy = trans[6]; matrix.Zz = trans[10];
                    workPart.ComponentAssembly.MoveComponent(newComponent, new Vector3d(trans[3], trans[7], trans[11]), matrix);

                    if (i != 0)
                    {
                        workPart.ComponentAssembly.MoveComponent(newComponent, (distance * i) * vector, new Snap.Orientation());
                    }
                }
            }
            else
            {
                NXOpen.Point point = null;
                if (!isHighlighted)
                {
                    var tempPoint = SnapEx.Helper.GetElecMidPointInPart(Snap.Globals.WorkPart, snapBody);
                    if (tempPoint != null)
                    {
                        point = tempPoint;
                    }
                }
                for (int i = 0; i < sum + 1; i++)
                {
                    var newBody = snapBody.Copy();
                    var guid    = Guid.NewGuid().ToString();
                    newBody.SetStringAttribute(SnapEx.EactConstString.EACT_ELECT_GROUP, guid);
                    newBody.SetDateTimeAttribute(EACT_POSITIONING_DATE, DateTime.Now);
                    tempObjs.Add(newBody);
                    var transForm = GetTransform(elecOrgin);
                    if (i != 0)
                    {
                        transForm = Snap.Geom.Transform.Composition(transForm, Snap.Geom.Transform.CreateTranslation((distance * i) * vector));
                    }

                    newBody.Move(transForm);
                    if (point != null)
                    {
                        Snap.NX.Point newPoint = Snap.NX.Point.Wrap(point.Tag).Copy();
                        newPoint.SetStringAttribute(SnapEx.EactConstString.EACT_ELECT_GROUP, guid);
                        newPoint.Move(transForm);
                    }
                }
            }

            if (toggleJiaju.Value && jiajuBody != null)
            {
                for (int i = 0; i < sum + 1; i++)
                {
                    Snap.NX.Body snapJiajuBody = jiajuBody;
                    var          newJiajuBody  = snapJiajuBody.Copy();
                    var          guid          = Guid.NewGuid().ToString();
                    newJiajuBody.Layer = body.Layer;
                    newJiajuBody.SetDateTimeAttribute(EACT_POSITIONING_DATE, DateTime.Now);
                    tempObjs.Add(newJiajuBody);
                    elecOrgin = new Snap.Position((snapBody.Box.MaxX + snapBody.Box.MinX) / 2, (snapBody.Box.MaxY + snapBody.Box.MinY) / 2, snapBody.Box.MinZ);
                    var transForm = GetTransform(elecOrgin);
                    if (i != 0)
                    {
                        transForm = Snap.Geom.Transform.Composition(transForm, Snap.Geom.Transform.CreateTranslation((distance * i) * vector));
                    }

                    newJiajuBody.Move(transForm);
                }
            }


            if (isHighlighted)
            {
                SnapEx.Create.DisplayModification(tempObjs);
            }
        }
    }
コード例 #11
0
ファイル: pubfun.cs プロジェクト: sadgood/410proj
    // private static UI theUI = null;


    public void function(string ToleranceValue, string PrimaryDatumReference, string SecondaryDatumReference, string TertiaryDatumReference, object ZoneShape, object MaterialModifier, object PrimaryMaterialCondition, object SecondaryMaterialCondition, object TertiaryMaterialCondition,
                         object frameStyle, double Annotationletter, double duanxian, Point3d point1, Point3d point2, NXObject guanlian)
    {
        NXOpen.Annotations.Fcf nullAnnotations_Fcf = null;
        NXOpen.Annotations.PmiFeatureControlFrameBuilder pmiFeatureControlFrameBuilder1;
        pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(nullAnnotations_Fcf);

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiFeatureControlFrameBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        pmiFeatureControlFrameBuilder1.Characteristic = NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic.ProfileOfASurface;


        pmiFeatureControlFrameBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        pmiFeatureControlFrameBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.Perpendicular = false;

        leaderData1.StubSize = duanxian;

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        TaggedObject taggedObject1;

        taggedObject1 = pmiFeatureControlFrameBuilder1.FeatureControlFrameDataList.FindItem(0);

        NXOpen.Annotations.FeatureControlFrameDataBuilder featureControlFrameDataBuilder1 = (NXOpen.Annotations.FeatureControlFrameDataBuilder)taggedObject1;

        featureControlFrameDataBuilder1.ZoneShape = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape)ZoneShape;

        featureControlFrameDataBuilder1.ToleranceValue = ToleranceValue;

        featureControlFrameDataBuilder1.MaterialModifier               = NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier.RegardlessOfFeatureSize;
        featureControlFrameDataBuilder1.PrimaryDatumReference.Letter   = PrimaryDatumReference;  //基准
        featureControlFrameDataBuilder1.SecondaryDatumReference.Letter = SecondaryDatumReference;
        featureControlFrameDataBuilder1.TertiaryDatumReference.Letter  = TertiaryDatumReference;
        if (PrimaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.PrimaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)PrimaryMaterialCondition;    //材料按顺序为L M 不填 S
        }

        if (SecondaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.SecondaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)SecondaryMaterialCondition;
        }

        if (TertiaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.TertiaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)TertiaryMaterialCondition;
        }

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        NXOpen.View nullView = null;
        assocOrigin1.View           = nullView;
        assocOrigin1.ViewOfGeometry = nullView;
        NXOpen.Point nullPoint = null;
        assocOrigin1.PointOnGeometry = nullPoint;

        assocOrigin1.VertAnnotation          = null;
        assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.HorizAnnotation         = null;
        assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.AlignedAnnotation       = null;
        assocOrigin1.DimensionLine           = 0;
        assocOrigin1.AssociatedView          = nullView;
        assocOrigin1.AssociatedPoint         = nullPoint;
        assocOrigin1.OffsetAnnotation        = null;
        assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.XOffsetFactor           = 0.0;
        assocOrigin1.YOffsetFactor           = 0.0;
        assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
        pmiFeatureControlFrameBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        pmiFeatureControlFrameBuilder1.FrameStyle = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle)frameStyle;    //单框复合框

        if (guanlian != null)
        {
            Type a = null;
            a = guanlian.GetType();
            if (a.Name == "Body")
            {
                Body guanl = (Body)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }    //关于关联的代码
            else if (a.Name == "Face")
            {
                Face guanl = (Face)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "Curve")
            {
                Curve guanl = (Curve)guanlian;
                bool  added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "Line")
            {
                Line guanl = (Line)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "Point")
            {
                Point guanl = (Point)guanlian;
                bool  added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiParallelDimension")
            {
                NXOpen.Annotations.PmiParallelDimension guanl = (NXOpen.Annotations.PmiParallelDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiArcLengthDimension")
            {
                NXOpen.Annotations.PmiArcLengthDimension guanl = (NXOpen.Annotations.PmiArcLengthDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiBaselineDimension")
            {
                NXOpen.Annotations.PmiBaselineDimension guanl = (NXOpen.Annotations.PmiBaselineDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiChainDimension")
            {
                NXOpen.Annotations.PmiChainDimension guanl = (NXOpen.Annotations.PmiChainDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiChamferDimension")
            {
                NXOpen.Annotations.PmiChamferDimension guanl = (NXOpen.Annotations.PmiChamferDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiConcentricCircleDimension")
            {
                NXOpen.Annotations.PmiConcentricCircleDimension guanl = (NXOpen.Annotations.PmiConcentricCircleDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiCylindricalDimension")
            {
                NXOpen.Annotations.PmiCylindricalDimension guanl = (NXOpen.Annotations.PmiCylindricalDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiDiameterDimension")
            {
                NXOpen.Annotations.PmiDiameterDimension guanl = (NXOpen.Annotations.PmiDiameterDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiHoleDimension")
            {
                NXOpen.Annotations.PmiHoleDimension guanl = (NXOpen.Annotations.PmiHoleDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiFoldedRadiusDimension")
            {
                NXOpen.Annotations.PmiFoldedRadiusDimension guanl = (NXOpen.Annotations.PmiFoldedRadiusDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiHorizontalDimension")
            {
                NXOpen.Annotations.PmiHorizontalDimension guanl = (NXOpen.Annotations.PmiHorizontalDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiHorizontalOrdinateDimension")
            {
                NXOpen.Annotations.PmiHorizontalOrdinateDimension guanl = (NXOpen.Annotations.PmiHorizontalOrdinateDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiMajorAngularDimension")
            {
                NXOpen.Annotations.PmiMajorAngularDimension guanl = (NXOpen.Annotations.PmiMajorAngularDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
            else if (a.Name == "PmiMinorAngularDimension")
            {
                NXOpen.Annotations.PmiMinorAngularDimension guanl = (NXOpen.Annotations.PmiMinorAngularDimension)guanlian;
                bool added1;
                added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanl);
            }
        }
        //NXOpen.Point point4;
        //point4 = workPart.Points.CreatePoint(point1);
        pmiFeatureControlFrameBuilder1.Origin.Origin.SetValue(null, nullView, point1);


        NXOpen.Point point3;
        point3 = workPart.Points.CreatePoint(point2);



        leaderData1.Leader.SetValue(point3, workPart.ModelingViews.WorkView, point2);    //折线


        // leaderData1.TerminatorType = NXOpen.Annotations.LeaderData.LeaderType.Flag;//标志
        // NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
        // Edge edge1 = (Edge)extrude1.FindObject("EDGE * 180 * 190 {(3,10,5)(3,10,0)(3,10,-5) EXTRUDE(2)}");
        // Point3d point2 = new Point3d(3.0, 10.0, 3.02209729734126);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point1);

        // leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.None;

        //// NXOpen.View nullView = null;
        // Point3d point3= new Point3d(3.0, 10.0, 5.0);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point2);


        NXObject nXObject1;

        nXObject1 = pmiFeatureControlFrameBuilder1.Commit();


        //样式设置
        NXOpen.Annotations.Fcf fcf1 = (NXOpen.Annotations.Fcf)nXObject1;

        NXOpen.Annotations.SymbolPreferences symbolPreferences1;
        symbolPreferences1 = fcf1.GetSymbolPreferences();

        NXOpen.Annotations.LineAndArrowPreferences lineAndArrowPreferences1;
        lineAndArrowPreferences1 = fcf1.GetLineAndArrowPreferences();

        NXOpen.Annotations.LetteringPreferences letteringPreferences1;
        letteringPreferences1 = fcf1.GetLetteringPreferences();
        lineAndArrowPreferences1.LeaderLocation = NXOpen.Annotations.VerticalTextJustification.Middle;

        fcf1.SetLineAndArrowPreferences(lineAndArrowPreferences1);
        NXOpen.Annotations.Lettering generalText1;
        generalText1.Size = Annotationletter;    //文本设置值
        generalText1.CharacterSpaceFactor = 0.5;
        generalText1.AspectRatio          = 0.57;
        generalText1.LineSpaceFactor      = 1.0;
        generalText1.Cfw.Color            = 211;
        generalText1.Cfw.Font             = 2;
        generalText1.Cfw.Width            = NXOpen.Annotations.LineWidth.Thin;
        letteringPreferences1.SetGeneralText(generalText1);
        fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromRight;
        //fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromLeft;
        fcf1.SetLetteringPreferences(letteringPreferences1);

        pmiFeatureControlFrameBuilder1.Destroy();
    }
コード例 #12
0
ファイル: GoldBeam.cs プロジェクト: tysonmaag/Midterm
    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);
        }
    }
コード例 #13
0
ファイル: pubfun.cs プロジェクト: sadgood/410proj
    public void SurfaceFinishFunction(string a, string d, object StandardType, object FinishType, Point3d point1, Face obj, NXOpen.Point point, Point testpoint)
    {
        //生成粗糙度符号
        NXOpen.Annotations.SurfaceFinish        nullAnnotations_SurfaceFinish = null;
        NXOpen.Annotations.SurfaceFinishBuilder surfaceFinishBuilder1;

        surfaceFinishBuilder1 = workPart.PmiManager.PmiAttributes.CreateSurfaceFinishBuilder(nullAnnotations_SurfaceFinish);

        surfaceFinishBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        surfaceFinishBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        surfaceFinishBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true);
        surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        surfaceFinishBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        surfaceFinishBuilder1.Title = "Surface Finish";

        surfaceFinishBuilder1.A1 = a;    // "Ra 0.025";//粗糙度

        surfaceFinishBuilder1.F1 = "";

        surfaceFinishBuilder1.Angle = 0.0;

        surfaceFinishBuilder1.D = d;                                                                         // "=";//放置符号

        surfaceFinishBuilder1.Standard = (NXOpen.Annotations.SurfaceFinishBuilder.StandardType)StandardType; //.Iso;//标准

        surfaceFinishBuilder1.Finish = (NXOpen.Annotations.SurfaceFinishBuilder.FinishType)FinishType;       //.MaterialRemovalRequired;//材料移除

        surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true);

        surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true);


        NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        NXOpen.View nullView = null;
        assocOrigin1.View           = nullView;
        assocOrigin1.ViewOfGeometry = nullView;
        NXOpen.Point nullPoint = testpoint;
        assocOrigin1.PointOnGeometry         = nullPoint;
        assocOrigin1.VertAnnotation          = null;
        assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.HorizAnnotation         = null;
        assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.AlignedAnnotation       = null;
        assocOrigin1.DimensionLine           = 0;
        assocOrigin1.AssociatedView          = nullView;
        assocOrigin1.AssociatedPoint         = nullPoint;
        assocOrigin1.OffsetAnnotation        = null;
        assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.XOffsetFactor           = 0.0;
        assocOrigin1.YOffsetFactor           = 0.0;
        assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
        surfaceFinishBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        //Point p=null;
        //try
        //{
        //    p.SetCoordinates(point1);
        //}
        //catch (Exception ex)
        //{
        //    UI.GetUI().NXMessageBox.Show("error",NXMessageBox.DialogType.Error,ex.ToString());
        //}
        surfaceFinishBuilder1.Origin.Origin.SetValue(null, nullView, point1);
        if (point != null)
        {
            Point3d point2 = point.Coordinates;                                          //折线点
            leaderData1.Leader.SetValue(point, workPart.ModelingViews.WorkView, point2); //折线
        }
        surfaceFinishBuilder1.Origin.SetInferRelativeToGeometry(true);
        bool added1;

        added1 = surfaceFinishBuilder1.AssociatedObjects.Objects.Add(obj);    //关联对象
        NXObject nXObject1;

        nXObject1 = surfaceFinishBuilder1.Commit();
        surfaceFinishBuilder1.Destroy();
    }
コード例 #14
0
ファイル: pubfun.cs プロジェクト: sadgood/410proj
    public void function(string ToleranceValue, string PrimaryDatumReference, string SecondaryDatumReference, string TertiaryDatumReference, object ZoneShape, object Characteristic, object MaterialModifier, object PrimaryMaterialCondition, object SecondaryMaterialCondition, object TertiaryMaterialCondition,
                         object frameStyle, double Annotationletter, double duanxian, Point3d point1, DisplayableObject point2, DisplayableObject guanlian, object LeaderType)
    {
        NXOpen.Annotations.Fcf nullAnnotations_Fcf = null;
        NXOpen.Annotations.PmiFeatureControlFrameBuilder pmiFeatureControlFrameBuilder1;
        pmiFeatureControlFrameBuilder1 = workPart.Annotations.CreatePmiFeatureControlFrameBuilder(nullAnnotations_Fcf);

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiFeatureControlFrameBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        pmiFeatureControlFrameBuilder1.Characteristic = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfCharacteristic)Characteristic;


        pmiFeatureControlFrameBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        pmiFeatureControlFrameBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.Perpendicular = false;

        leaderData1.StubSize = duanxian;

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        TaggedObject taggedObject1;

        taggedObject1 = pmiFeatureControlFrameBuilder1.FeatureControlFrameDataList.FindItem(0);

        NXOpen.Annotations.FeatureControlFrameDataBuilder featureControlFrameDataBuilder1 = (NXOpen.Annotations.FeatureControlFrameDataBuilder)taggedObject1;

        featureControlFrameDataBuilder1.ZoneShape = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceZoneShape)ZoneShape;

        featureControlFrameDataBuilder1.ToleranceValue = ToleranceValue;

        featureControlFrameDataBuilder1.MaterialModifier               = (NXOpen.Annotations.FeatureControlFrameDataBuilder.ToleranceMaterialModifier)MaterialModifier;
        featureControlFrameDataBuilder1.PrimaryDatumReference.Letter   = PrimaryDatumReference;  //基准
        featureControlFrameDataBuilder1.SecondaryDatumReference.Letter = SecondaryDatumReference;
        featureControlFrameDataBuilder1.TertiaryDatumReference.Letter  = TertiaryDatumReference;
        if (PrimaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.PrimaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)PrimaryMaterialCondition;    //材料按顺序为L M 不填 S
        }

        if (SecondaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.SecondaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)SecondaryMaterialCondition;
        }

        if (TertiaryMaterialCondition != null)
        {
            featureControlFrameDataBuilder1.TertiaryDatumReference.MaterialCondition = (NXOpen.Annotations.DatumReferenceBuilder.DatumReferenceMaterialCondition)TertiaryMaterialCondition;
        }

        pmiFeatureControlFrameBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        NXOpen.View nullView = null;
        assocOrigin1.View           = nullView;
        assocOrigin1.ViewOfGeometry = nullView;
        NXOpen.Point nullPoint = null;
        assocOrigin1.PointOnGeometry = nullPoint;

        assocOrigin1.VertAnnotation          = null;
        assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.HorizAnnotation         = null;
        assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.AlignedAnnotation       = null;
        assocOrigin1.DimensionLine           = 0;
        assocOrigin1.AssociatedView          = nullView;
        assocOrigin1.AssociatedPoint         = nullPoint;
        assocOrigin1.OffsetAnnotation        = null;
        assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.XOffsetFactor           = 0.0;
        assocOrigin1.YOffsetFactor           = 0.0;
        assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
        pmiFeatureControlFrameBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        pmiFeatureControlFrameBuilder1.FrameStyle = (NXOpen.Annotations.FeatureControlFrameBuilder.FcfFrameStyle)frameStyle;    //单框复合框

        if (guanlian != null)
        {
            bool added1;
            added1 = pmiFeatureControlFrameBuilder1.AssociatedObjects.Objects.Add(guanlian);
        }
        //NXOpen.Point point4;
        //point4 = workPart.Points.CreatePoint(point1);
        pmiFeatureControlFrameBuilder1.Origin.Origin.SetValue(null, nullView, point1);

        point2.Highlight();
        try
        {
            //    if (LeaderType.Equals(NXOpen.Annotations.LeaderData.LeaderType.Plain))
            //    {
            leaderData1.TerminatorType = (NXOpen.Annotations.LeaderData.LeaderType)LeaderType;
            NXOpen.Point point3 = (Point)point2;
            // point3 = workPart.Points.CreatePoint(point2);

            Point3d p = point3.Coordinates;
            leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, p);        //折线
            // }
        }
        catch (Exception ex)
        { UI.GetUI().NXMessageBox.Show("error", NXMessageBox.DialogType.Error, ex.ToString()); }
        //else
        //{
        //    leaderData1.TerminatorType =(NXOpen.Annotations.LeaderData.LeaderType)LeaderType;//标志
        //    NXOpen.Edge point3 = (Edge)point2;
        //    double[] p1=new double[3];
        //    double[] p2=new double[3];
        //    int v;
        //    theUfSession.Modl.AskEdgeVerts(point3.Tag,p1,p2,out v);
        //    double[] p3 = new double[3];
        //    p3[0] = (p1[0] + p2[0]) / 2;
        //    p3[1] = (p1[1] + p2[1]) / 2;
        //    p3[2] = (p1[2] + p2[2]) / 2;
        //    Point3d pp = new Point3d(p3[0], p3[0], p3[0]);
        //    // //Point3d p = point3.Coordinates;
        //   leaderData1.Leader.SetValue(point2, workPart.ModelingViews.WorkView, pp);//折线
        //}
        // NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
        // Edge edge1 = (Edge)extrude1.FindObject("EDGE * 180 * 190 {(3,10,5)(3,10,0)(3,10,-5) EXTRUDE(2)}");
        // Point3d point2 = new Point3d(3.0, 10.0, 3.02209729734126);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point1);

        // leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.None;

        //// NXOpen.View nullView = null;
        // Point3d point3= new Point3d(3.0, 10.0, 5.0);
        // leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point2);


        NXObject nXObject1;

        nXObject1 = pmiFeatureControlFrameBuilder1.Commit();


        //样式设置
        NXOpen.Annotations.Fcf fcf1 = (NXOpen.Annotations.Fcf)nXObject1;

        NXOpen.Annotations.SymbolPreferences symbolPreferences1;
        symbolPreferences1 = fcf1.GetSymbolPreferences();

        NXOpen.Annotations.LineAndArrowPreferences lineAndArrowPreferences1;
        lineAndArrowPreferences1 = fcf1.GetLineAndArrowPreferences();

        NXOpen.Annotations.LetteringPreferences letteringPreferences1;
        letteringPreferences1 = fcf1.GetLetteringPreferences();
        lineAndArrowPreferences1.LeaderLocation = NXOpen.Annotations.VerticalTextJustification.Middle;

        fcf1.SetLineAndArrowPreferences(lineAndArrowPreferences1);
        NXOpen.Annotations.Lettering generalText1;
        generalText1.Size = Annotationletter;    //文本设置值
        generalText1.CharacterSpaceFactor = 0.5;
        generalText1.AspectRatio          = 0.57;
        generalText1.LineSpaceFactor      = 1.0;
        generalText1.Cfw.Color            = 211;
        generalText1.Cfw.Font             = 2;
        generalText1.Cfw.Width            = NXOpen.Annotations.LineWidth.Thin;
        letteringPreferences1.SetGeneralText(generalText1);
        fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromRight;
        //fcf1.LeaderOrientation = NXOpen.Annotations.LeaderOrientation.FromLeft;
        fcf1.SetLetteringPreferences(letteringPreferences1);

        pmiFeatureControlFrameBuilder1.Destroy();
    }
コード例 #15
0
ファイル: Position.cs プロジェクト: suifengsigan/TEST_1
 public Position(NXOpen.Point pt)
 {
     this.X = pt.Coordinates.X;
     this.Y = pt.Coordinates.Y;
     this.Z = pt.Coordinates.Z;
 }
コード例 #16
0
ファイル: Vector.cs プロジェクト: suifengsigan/TEST_1
 public Vector(NXOpen.Point pt)
 {
     this.X = pt.Coordinates.X;
     this.Y = pt.Coordinates.Y;
     this.Z = pt.Coordinates.Z;
 }
コード例 #17
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");
    }
コード例 #18
0
    public void function_note(string[] zhushiwenzi, DisplayableObject guanlian, NXObject zhiyinobj, Point3d placeptobj)
    {
        NXOpen.Annotations.SimpleDraftingAid nullAnnotations_SimpleDraftingAid = null;
        NXOpen.Annotations.PmiNoteBuilder    pmiNoteBuilder1;
        pmiNoteBuilder1 = workPart.Annotations.CreatePmiNoteBuilder(nullAnnotations_SimpleDraftingAid);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter;

        pmiNoteBuilder1.TextAlignment = NXOpen.Annotations.DraftingNoteBuilder.TextAlign.Middle;

        pmiNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.ModelView;

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        NXOpen.Annotations.LeaderData leaderData1;
        leaderData1 = workPart.Annotations.CreateLeaderData();

        leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow;

        pmiNoteBuilder1.Leader.Leaders.Append(leaderData1);

        leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred;

        leaderData1.StubSize = 5.0;

        leaderData1.Perpendicular = false;

        //double symbolscale1;
        //symbolscale1 = pmiNoteBuilder1.Text.TextBlock.SymbolScale;

        //double symbolaspectratio1;
        //symbolaspectratio1 = pmiNoteBuilder1.Text.TextBlock.SymbolAspectRatio;

        Xform xform1;

        xform1 = workPart.Annotations.GetDefaultAnnotationPlane(NXOpen.Annotations.PmiDefaultPlane.ModelView);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        //pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);

        pmiNoteBuilder1.Text.TextBlock.SetText(zhushiwenzi);

        NXOpen.Annotations.Annotation.AssociativeOriginData assocOrigin1;
        assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag;
        NXOpen.View nullView = null;
        assocOrigin1.View           = nullView;
        assocOrigin1.ViewOfGeometry = nullView;
        NXOpen.Point nullPoint = null;
        assocOrigin1.PointOnGeometry         = nullPoint;
        assocOrigin1.VertAnnotation          = null;
        assocOrigin1.VertAlignmentPosition   = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.HorizAnnotation         = null;
        assocOrigin1.HorizAlignmentPosition  = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.AlignedAnnotation       = null;
        assocOrigin1.DimensionLine           = 0;
        assocOrigin1.AssociatedView          = nullView;
        assocOrigin1.AssociatedPoint         = nullPoint;
        assocOrigin1.OffsetAnnotation        = null;
        assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft;
        assocOrigin1.XOffsetFactor           = 0.0;
        assocOrigin1.YOffsetFactor           = 0.0;
        assocOrigin1.StackAlignmentPosition  = NXOpen.Annotations.StackAlignmentPosition.Above;
        pmiNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1);

        bool added1;

        added1 = pmiNoteBuilder1.AssociatedObjects.Objects.Add(guanlian);


        pmiNoteBuilder1.Origin.Origin.SetValue(null, nullView, placeptobj);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);


        NXOpen.Features.Extrude extrude1 = (NXOpen.Features.Extrude)workPart.Features.FindObject("EXTRUDE(3)");
        Edge edge1 = (Edge)extrude1.FindObject("EDGE * 120 * 140 {(11,2,-5)(11,0.5,-5)(11,-1,-5) EXTRUDE(2)}");

        Point3d point2 = new Point3d(11.0, -1, -5.0);

        leaderData1.Leader.SetValue(edge1, workPart.ModelingViews.WorkView, point2);

        NXObject nXObject1;

        nXObject1 = pmiNoteBuilder1.Commit();

        pmiNoteBuilder1.Destroy();
    }