public static Expression CreateDim(NXObject obj1, NXObject obj2, Point3d dimOrigin, NXOpen.Annotations.DimensionMeasurementBuilder.MeasurementMethod method, InferSnapType.SnapType type)
        {
            Part workPart = theSession.Parts.Work;

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

            sketchLinearDimensionBuilder1.SecondAssociativity.SetValue(type, obj2, null, point1, null, nullNXOpen_View, point1);
            sketchLinearDimensionBuilder1.FirstAssociativity.SetValue(type, obj1, null, point1, null, nullNXOpen_View, point1);
            sketchLinearDimensionBuilder1.Origin.Origin.SetValue(null, nullNXOpen_View, dimOrigin);
            try
            {
                NXOpen.NXObject nXObject1;
                nXObject1 = sketchLinearDimensionBuilder1.Commit();
                Expression exp = sketchLinearDimensionBuilder1.Driving.ExpressionValue;
                return(exp);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("SketchUtils:CreateDimForLine:" + ex.Message);
                throw ex;
            }
            finally
            {
                sketchLinearDimensionBuilder1.Destroy();
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
    // 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();
    }
Exemple #4
0
    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();
    }
Exemple #5
0
    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();
    }
Exemple #6
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();
    }