示例#1
0
        /// <summary>
        /// 添加注释
        /// </summary>
        /// <param name="point"></param>
        /// <param name="size"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static NXObject SetNote(Point3d point, double size, params string[] text)
        {
            Part workPart = theSession.Parts.Work;

            NXOpen.Annotations.SimpleDraftingAid   nullNXOpen_Annotations_SimpleDraftingAid = null;
            NXOpen.Annotations.DraftingNoteBuilder draftingNoteBuilder1;
            draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullNXOpen_Annotations_SimpleDraftingAid);
            int fontIndex1;

            fontIndex1 = workPart.Fonts.AddFont("宋体", NXOpen.FontCollection.Type.Standard);
            draftingNoteBuilder1.Style.LetteringStyle.GeneralTextSize  = size;
            draftingNoteBuilder1.Style.LetteringStyle.AppendedTextFont = fontIndex1;
            draftingNoteBuilder1.Style.LetteringStyle.GeneralTextColor = workPart.Colors.Find(6);
            draftingNoteBuilder1.Text.TextBlock.SetText(text);
            NXOpen.View nullNXOpen_View = null;
            draftingNoteBuilder1.Origin.Origin.SetValue(null, nullNXOpen_View, point);
            try
            {
                NXOpen.NXObject nXObject1;
                nXObject1 = draftingNoteBuilder1.Commit();
                return(nXObject1);
            }
            catch (NXException ex)
            {
                LogMgr.WriteLog("DrawingUtils:SetNote" + ex.Message);
                throw ex;;
            }
            finally
            {
                draftingNoteBuilder1.Destroy();
            }
        }
示例#2
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, null, placeptobj);

        pmiNoteBuilder1.Origin.SetInferRelativeToGeometry(true);
        if (zhiyinobj != null)
        {
            Point   zhiyin     = (Point)zhiyinobj;
            Point3d zhiyindian = zhiyin.Coordinates;
            //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)}");
            //edge1.GetVertices();
            leaderData1.Leader.SetValue(zhiyin, workPart.ModelingViews.WorkView, zhiyindian);
        }
        NXObject nXObject1;

        nXObject1 = pmiNoteBuilder1.Commit();

        pmiNoteBuilder1.Destroy();
    }