Showing results for 
Search instead for 
Do you mean 

Preferences->Annotations->Load all defaults through programming in NX8

Hi All,

I have a task to load all defaults for Annotation preferences through programming, but I could not find any API or easy functionality to achive this. Has anybody any idea to do this?





Re: Preferences->Annotations->Load all defaults through programming in NX8

Use a macro for default setting and run the macro through program.

Re: Preferences->Annotations->Load all defaults through programming in NX8

Thanks for your quick reply, just now I posted another question on community regarding executing a Macro from program, is it possible to call a macro from program?

Re: Preferences->Annotations->Load all defaults through programming in NX8

[ Edited ]

One way I could think of is using send keys. Use the shortcut keys for macro playback , paste the location and enter.

Re: Preferences->Annotations->Load all defaults through programming in NX8

It wouldn't be easy, but the API does give you access to the customer defaults and the part preferences. Below is some code that I wrote a while back that compares some drafting values in the part vs. the customer default value. This code simply reports the values, but you could easily take the customer default value and assign it to the part preferences.


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        If IsNothing(theSession.Parts.Work) Then
            'active part required
        End If

        Dim workPart As Part = theSession.Parts.Work

        'get work part preferences
        Dim arrowLengthA As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.ArrowheadLength
        Dim arrowAngleB As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.ArrowheadIncludedAngle
        Dim dotDiameterC As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.DotArrowheadDiameter
        Dim stubSizeD As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.StubLength
        Dim extensionLengthE As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.LinePastArrowDistance
        Dim extensionAngleF As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.ObliqueExtensionLineAngle
        Dim dimTextToLineG As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.TextToLineDistance
        Dim extLine1GapH As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.FirstPosToExtLineDist
        Dim extLine2GapJ As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.SecondPosToExtLineDist
        Dim datumArrowExtensionK As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.DatumLengthPastArrow
        Dim textOverStubGapL As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.TextOverStubSpaceFactor
        Dim textOverLeaderGapM As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.TextOverLeaderGapFactor
        Dim allAroundSymbolIdN As Double = workPart.Annotations.Preferences.GetLineAndArrowPreferences.AllAroundSymbol

        'get customer default preferences
        Dim cdArrowLengthA As Double
        Dim cdArrowAngleB As Double
        Dim cdDotDiameterC As Double
        Dim cdStubSizeD As Double
        Dim cdExtensionLengthE As Double
        Dim cdExtensionAngleF As Double
        Dim cdDimTextToLineG As Double
        Dim cdExtLine1GapH As Double
        Dim cdExtLine2GapJ As Double
        Dim cdDatumArrowExtensionK As Double
        Dim cdTextOverStubGapL As Double
        Dim cdTextOverLeaderGapM As Double
        Dim cdAllAroundSymbolIdN As Double

        If workPart.PartUnits = BasePart.Units.Millimeters Then
            'metric part units
            cdArrowLengthA = theSession.OptionsManager.GetRealValue("Drafting_arrowSize_MU")
            cdDotDiameterC = theSession.OptionsManager.GetRealValue("Drafting_dotDiameter_MU")
            cdStubSizeD = theSession.OptionsManager.GetRealValue("Drafting_stubbSize_MU")
            cdExtensionLengthE = theSession.OptionsManager.GetRealValue("Drafting_lineArrow_MU")

            cdDimTextToLineG = theSession.OptionsManager.GetRealValue("Drafting_textLine_MU")
            cdExtLine1GapH = theSession.OptionsManager.GetRealValue("Drafting_pointLine1_MU")
            cdExtLine2GapJ = theSession.OptionsManager.GetRealValue("Drafting_pointLine2_MU")
            cdDatumArrowExtensionK = theSession.OptionsManager.GetRealValue("Drafting_datumExtLine_MU")

            cdAllAroundSymbolIdN = theSession.OptionsManager.GetRealValue("Drafting_allAroundSymbolSize_MU")

            'english part units
            cdArrowLengthA = theSession.OptionsManager.GetRealValue("Drafting_arrowSize_EU")
            cdDotDiameterC = theSession.OptionsManager.GetRealValue("Drafting_dotDiameter_EU")
            cdStubSizeD = theSession.OptionsManager.GetRealValue("Drafting_stubbSize_EU")
            cdExtensionLengthE = theSession.OptionsManager.GetRealValue("Drafting_lineArrow_EU")

            cdDimTextToLineG = theSession.OptionsManager.GetRealValue("Drafting_textLine_EU")
            cdExtLine1GapH = theSession.OptionsManager.GetRealValue("Drafting_pointLine1_EU")
            cdExtLine2GapJ = theSession.OptionsManager.GetRealValue("Drafting_pointLine2_EU")
            cdDatumArrowExtensionK = theSession.OptionsManager.GetRealValue("Drafting_datumExtLine_EU")

            cdAllAroundSymbolIdN = theSession.OptionsManager.GetRealValue("Drafting_allAroundSymbolSize_EU")

        End If

        'get values that are independent of part units
        cdArrowAngleB = theSession.OptionsManager.GetRealValue("Drafting_includedAngle")
        cdExtensionAngleF = theSession.OptionsManager.GetRealValue("Drafting_extensionLineAngle")
        cdTextOverStubGapL = theSession.OptionsManager.GetRealValue("Drafting_textOverStubFactor")
        cdTextOverLeaderGapM = theSession.OptionsManager.GetRealValue("Drafting_textOverLeaderGapFactor")

        lw.WriteLine("Compare value of Customer Default (CD) setting to Part File (PF)")

        PrintResult("Arrowhead length (A)", cdArrowLengthA, arrowLengthA)
        PrintResult("Arrowhead included angle (B)", cdArrowAngleB, arrowAngleB)
        PrintResult("Dot diameter size (C)", cdDotDiameterC, dotDiameterC)
        PrintResult("Stub Length (D)", cdStubSizeD, stubSizeD)
        PrintResult("Line past arrow (E)", cdExtensionLengthE, extensionLengthE)
        PrintResult("Extension line angle (F)", cdExtensionAngleF, extensionAngleF)
        PrintResult("Gap text to line (G)", cdDimTextToLineG, dimTextToLineG)
        PrintResult("Extension line 1 gap (H)", cdExtLine1GapH, extLine1GapH)
        PrintResult("Extension line 2 gap (J)", cdExtLine2GapJ, extLine2GapJ)
        PrintResult("Datum extension (K)", cdDatumArrowExtensionK, datumArrowExtensionK)
        PrintResult("Text over stub factor (L)", cdTextOverStubGapL, textOverStubGapL)
        PrintResult("Text over leader factor (M)", cdTextOverLeaderGapM, textOverLeaderGapM)
        PrintResult("All around symbol size ID (N)", cdAllAroundSymbolIdN, allAroundSymbolIdN)



    End Sub

    Sub PrintResult(ByVal title As String, ByVal CdValue As Double, ByVal PfValue As Double)

        If PfValue.Equals(CdValue) Then
            lw.WriteLine("  $$ Huzzah! they match $$")
            lw.WriteLine("  ## Oh no! they don't match ##")
        End If
        lw.WriteLine("CD value: " & CdValue.ToString)
        lw.WriteLine("PF value: " & PfValue.ToString)

    End Sub

    Sub ListOption(ByVal theOption As String)

        'lw.WriteLine("value set at site level: " & theSession.OptionsManager.IsValueSet(theOption, Options.LevelType.Site).ToString)
        'lw.WriteLine("locked at site level: " & theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Site))

        Select Case theSession.OptionsManager.GetOptionType(theOption)
            Case Is = Options.OptionType.String
                lw.WriteLine("value type: string")
                lw.WriteLine("value: " & theSession.OptionsManager.GetStringValue(theOption))

            Case Is = Options.OptionType.Int
                lw.WriteLine("value type: integer")
                lw.WriteLine("value: " & theSession.OptionsManager.GetIntValue(theOption))

            Case Is = Options.OptionType.Real
                lw.WriteLine("value type: real")
                lw.WriteLine("value: " & theSession.OptionsManager.GetRealValue(theOption))

            Case Is = Options.OptionType.Logical
                lw.WriteLine("value type: boolean")
                lw.WriteLine("value: " & theSession.OptionsManager.GetLogicalValue(theOption))

            Case Else
                'skip other types for now...
                lw.WriteLine("value type: other")
                lw.WriteLine("option type not accounted for: " & theSession.OptionsManager.GetOptionType(theOption).ToString)

        End Select


    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

Re: Preferences->Annotations->Load all defaults through programming in NX8

How about recording a journal of the manual action to see how it is done?

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 ( | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: Preferences->Annotations->Load all defaults through programming in NX8

[ Edited ]

Unfortunately, nothing gets recorded in this case (at least not in NX 9).

Re: Preferences->Annotations->Load all defaults through programming in NX8

Recording a journal does not gives complete info, also programming to set all defaults is too complex. I got help from another discussion regarding calling a macro from program, so I am calling a macro to load all defaults. I am not complete satisfied to call a macro from program but for now this is the only best way to do it that I can see. In higher versions NX9 or NX10 I have seen in documentation a functionality under NXOpen.Annotations->EditSettingsBuilder->InheritSettingsFromCustomerDefault() but not sure how it works or what it does.

Re: Preferences->Annotations->Load all defaults through programming in NX8

I think it is the same as pushing the button to inherit the annotation setting from the customer defaults in the annotation preferences dialog.

I think there has also been an enhancement request to be able to set all annotation defaults from the customer defaults through API for a long time, might be this is the solution.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 ( | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community