Submitted by mknauss on Wed, 09/17/2014 - 04:57
Forums:
Hello!
Is there a way to call the function "Load All Defaults" in Annotation Preferences via Journal?
We want to set the Drafting Standard (that part already works) and then load the missing Preferences from Customer Defaults.
Thanks for help!
Regards, Martin
re: default options
If you know the name of the value you are looking for, you can query the session values to find it. Some sample code is below that will show some site level values for various dimension options. Also in the code is a way to list all available options; the ones you want probably start with "Drafting_".
Option Strict Off
Imports System
Imports NXOpen
Module Module1
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
lw.Open()
Const undoMarkName As String = "Report Default Option"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
'** uncomment the following lines to write out all options
'** warning: there are 1000's!
'** Save the listing window results as a text file, import into Excel, and sort
'** the options to make it easier to find the desired option(s).
'Dim myOptions() As String
'myOptions = theSession.OptionsManager.GetAllOptions
'For Each temp As String In myOptions
' lw.WriteLine(temp)
'Next
Try
ListOption("Drafting_dimAppTextSpaceFactor")
ListOption("Drafting_dimDimLineSpaceFactor")
ListOption("Drafting_dimensionArrowOutLengthFactor")
ListOption("Drafting_dimensionDecimalPlaces_EU")
ListOption("Drafting_dimensionDecimalPlaces_MU")
ListOption("Drafting_dimLeadingZeros_EU")
ListOption("Drafting_dimLeadingZeros_MU")
ListOption("Drafting_dimLineBetweenExtLine")
ListOption("Drafting_dimTextAspectRatio")
ListOption("Drafting_dimTextCharSize_EU")
ListOption("Drafting_dimTextCharSize_MU")
ListOption("Drafting_dimTextColor_EU")
ListOption("Drafting_dimTextColor_MU")
ListOption("Drafting_dimTextFont")
ListOption("Drafting_dimTextFontStyle")
ListOption("Drafting_dimTextLineFactor")
ListOption("Drafting_dimTextSpaceFactor")
ListOption("Drafting_dimTextWidth")
ListOption("Drafting_dimToleranceConversion")
ListOption("Drafting_dimTolTextSpaceFactor")
ListOption("Drafting_dimTrailingZeros_EU")
ListOption("Drafting_dimTrailingZeros_MU")
Catch ex As NXException
theSession.UndoToMark(markId1, undoMarkName)
MsgBox(ex.Message)
Finally
End Try
lw.Close()
End Sub
Sub ListOption(ByVal theOption As String)
lw.WriteLine(theOption)
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("site level value: " & theSession.OptionsManager.GetStringValue(theOption, Options.LevelType.Site))
Case Is = Options.OptionType.Int
lw.WriteLine("site level value: " & theSession.OptionsManager.GetIntValue(theOption, Options.LevelType.Site))
Case Is = Options.OptionType.Real
lw.WriteLine("site level value: " & theSession.OptionsManager.GetRealValue(theOption, Options.LevelType.Site))
Case Is = Options.OptionType.Logical
lw.WriteLine("site level value: " & theSession.OptionsManager.GetLogicalValue(theOption, Options.LevelType.Site))
Case Else
'skip other types for now...
lw.WriteLine("option type not accounted for: " & theSession.OptionsManager.GetOptionType(theOption).ToString)
End Select
lw.WriteLine("")
'lw.WriteLine(theOption)
'lw.WriteLine("value set at group level: " & theSession.OptionsManager.IsValueSet(theOption, Options.LevelType.Group).ToString)
'lw.WriteLine("locked at group level: " & theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Group))
'lw.WriteLine("group level value: " & theSession.OptionsManager.GetStringValue(theOption, Options.LevelType.Group))
'lw.WriteLine("")
'lw.WriteLine(theOption)
'lw.WriteLine("value set at user level: " & theSession.OptionsManager.IsValueSet(theOption, Options.LevelType.User).ToString)
'lw.WriteLine("locked at user level: " & theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.User))
'lw.WriteLine("user level value: " & theSession.OptionsManager.GetStringValue(theOption, Options.LevelType.User))
'lw.WriteLine("")
End Sub
End Module
Hello!
Hello!
Thanks for this interesting code.
The results are very helpful!
But I see that it would be easier to tell the users to press the Button "Load All Defaults" in Annotation Preferences Dialog.
Maybe sometimes there will be an API-function to manage this action in "one" step. Maybe?!?!
Kind regards, Martin