cancel
Showing results for 
Search instead for 
Did you mean: 

LetteringPreferences

I wrote this code to coloring all the dimensions but some dimensions disappear.

does anyone knows why? NX8.5

 

Thanks in advance

 

 

using System;
using NXOpen;
using NXOpen.UF;
using NXOpen.Annotations;
using NXOpen.Drawings;

namespace COLOR
{

    public class Class1
    {
        public static void Main(string[] args)
        {
            Session theSession = Session.GetSession();
            Part workPart = theSession.Parts.Work;
            Part displayPart = theSession.Parts.Display;

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

            foreach (Dimension dim1 in workPart.Dimensions)
            {
                LetteringPreferences letteringPreferences1;
                letteringPreferences1 = dim1.GetLetteringPreferences();


                NXOpen.Annotations.Lettering dimText1;
                dimText1 = letteringPreferences1.GetDimensionText();
                dimText1.Size = .250;
                dimText1.Cfw.Color = 216;
                letteringPreferences1.SetDimensionText(dimText1);

                NXOpen.Annotations.Lettering tolText1;
                tolText1 = letteringPreferences1.GetToleranceText();
                tolText1.Size = .250;
                tolText1.Cfw.Color = 216;

                letteringPreferences1.SetToleranceText(tolText1);

                NXOpen.Annotations.Lettering genText;
                genText = letteringPreferences1.GetGeneralText();
                genText.Size = .250;
                genText.Cfw.Color = 216;
                letteringPreferences1.SetGeneralText(genText);

                NXOpen.Annotations.Lettering appText;
                appText = letteringPreferences1.GetAppendedText();
                appText.Size = .250;
                appText.Cfw.Color = 216;
                letteringPreferences1.SetAppendedText(appText);

                dim1.SetLetteringPreferences(letteringPreferences1);

                letteringPreferences1.Dispose();

                LineAndArrowPreferences lineAndArrowPreferences1;
                lineAndArrowPreferences1 = dim1.GetLineAndArrowPreferences();

                NXOpen.Annotations.LineCfw firstExtensionLineCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetFirstExtensionLineCfw(firstExtensionLineCfw1);

                NXOpen.Annotations.LineCfw firstArrowheadCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetFirstArrowheadCfw(firstArrowheadCfw1);

                NXOpen.Annotations.LineCfw firstArrowLineCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetFirstArrowLineCfw(firstArrowLineCfw1);

                NXOpen.Annotations.LineCfw secondExtensionLineCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetSecondExtensionLineCfw(secondExtensionLineCfw1);

                NXOpen.Annotations.LineCfw secondArrowheadCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetSecondArrowheadCfw(secondArrowheadCfw1);

                NXOpen.Annotations.LineCfw secondArrowLineCfw1 = new NXOpen.Annotations.LineCfw(216, NXOpen.DisplayableObject.ObjectFont.Solid, NXOpen.Annotations.LineWidth.Thin);
                lineAndArrowPreferences1.SetSecondArrowLineCfw(secondArrowLineCfw1);

                dim1.SetLineAndArrowPreferences(lineAndArrowPreferences1);

                lineAndArrowPreferences1.Dispose();




                int nErrs1;
                nErrs1 = theSession.UpdateManager.DoUpdate(markId1);
            }

          

            foreach (DraftingView view1 in workPart.DraftingViews)
            {

                workPart.DraftingViews.SuppressViewBreaks(view1);
                view1.Style.VisibleLines.VisibleColor = 216;
                view1.Style.HiddenLines.HiddenlineColor = 216;
                view1.Commit();
                workPart.DraftingViews.RestoreViewBreaks(view1);
            }


        }

        public static int GetUnloadOption(string dummy) { return (int)Session.LibraryUnloadOption.Immediately; }
    }

}







 

6 REPLIES

Re: LetteringPreferences

Phenom
Phenom

What setting are you using for retained annotations? (drafting preferences -> general/setup -> retained annotations -> show retained annotations)

 

I would guess that the 'show retained annotations' option is turned off. In your video, the dimension on the right looks like it loses its horizontal reference; there is a thin horizontal line visible at the start of the video, but it disappears when the view updates. Probably something similar is happening to the other dimension as well.

Re: LetteringPreferences

that line is a 2d Centerline and its gone too.

 

and my drafting preferences..

 

retained annotations

Re: LetteringPreferences

Esteemed Contributor
Esteemed Contributor

If you try to "rectange select" (or just "select all") (or just switch to monochrome view) - do the missing objects show up?

 

If so, the dimension color may be set to the same color as the background.

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: LetteringPreferences


Ken_A wrote:

do the missing objects show up?

  


 

No.. the only way to show the missing dimension it's just when i run the code again....
but in the end disappear.

Re: LetteringPreferences

Legend
Legend

It could be part specific.  Have you tried this on different part file.  I tried your journal code in NX8 and NX10 and did not find any problems.

Re: LetteringPreferences

sorry for the late response.. I been working on different assignments..

but.. it seems that the problem is with some dimensions that uses geometry on diferent views.. this is what i have so far..

 

I found one different solution on the solution center.. it uses inherit annotation settings from template (nx_api5593) but.. it seems that "editSettingsBuilder"(NXOpen.Annotations.EditSettingsBuilder) has been deprecated or something.

 

using the code "as is" do not work.. so with a little more work/investigation maybe i can achieve what i want. i would like to try this solution and see what happens.

 

Thank you all for your comments.. !!