Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to list all customer defaults editable by the user

Is there any way to list the customer defaults that a user can change at user level?

The user can access the group level, which is read-only, and check the ones that are not locked at this level, but this is not a nice way in my opinion.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.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
6 REPLIES

Re: How to list all customer defaults editable by the user

I think the easiest would be to export the C.D.s to an Excel file, then sort on the "locked" columns to see if anything is locked at the site/group level.

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: How to list all customer defaults editable by the user

[ Edited ]

Below is a rudimentary journal that will list all of the options that are not locked at the site or group level. Perhaps it can serve as a starting point for what you are after.

 

Edit: did not see @Ken_A's post until after I posted. I think his solution is better than using the journal below.

 

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen

Module user_editable_options

    Dim theSession As Session = Session.GetSession()

    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        lw.Open()

        Dim userEditableOptions As New List(Of String)
        For Each temp As String In theSession.OptionsManager.GetAllOptions
            If IsOptionUserEditable(temp) Then
                userEditableOptions.Add(temp)
            End If
        Next

        lw.WriteLine("writing user editable options to text file...")

        'write option information to a text file in the user's "my documents" folder
        Dim myDocs As String
        Const fileName As String = "NX_user_options.txt"
        myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        Dim outputFile As String = IO.Path.Combine(myDocs, fileName)

        'pass False to overwrite existing file, True to append existing file
        'if file does not exist, a new file will be created and the True/False value will be ignored
        Using myWriter As New IO.StreamWriter(outputFile, False)

            For Each temp As String In userEditableOptions
                myWriter.WriteLine(temp)
            Next

        End Using

        lw.WriteLine("user options written to: " & outputFile)
        lw.WriteLine("Import the file to Excel for sorting.")

    End Sub

    Function IsOptionUserEditable(ByVal theOption As String) As Boolean

        'user cannot edit options locked at the site level
        If theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Site) Then
            Return False
        End If

        'user cannot edit options locked at the group level
        If theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Group) Then
            Return False
        End If

        'user can edit all other options
        Return True

    End Function

    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: How to list all customer defaults editable by the user

[ Edited ]

Thanks Ken, but the last time I tried to export the customer defaults to Excel, NX hung and Excel crashed.

There are 50000+ CDs, so that is not something I would consider a work-around.

Thanks Cowski, I will check your NXOpen API solution, seems to be more reliable and can be run at any time repeatedly Smiley Wink

Sorting can be done on the list:

userEditableOptions.TrimExcess()
userEditableOptions.Sort()
Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.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: How to list all customer defaults editable by the user

[ Edited ]

A quick check of the journal showed that there is more to do.

We don't lock defaults at site level to be able to change drafting settings at group level without having to copy the entire drafting standard.

I will have to take a look at IsLevelLockedByDefault for that matter.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.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: How to list all customer defaults editable by the user

Hmmm...I've never had a problem exporting CDs to Excel.

And yes, I know how many there are, that was why I suggested sorting on the columns.

 

Note that the info in the DPV files is text (XML) so (maybe) it would be easier to parse the site & group DPV files to see what is locked? 

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


Solution
Solution
Accepted by topic author Stefan_Pendl
‎01-31-2017 03:48 AM

Re: How to list all customer defaults editable by the user

Reading the remarks of the available methods resulted in the following code.

'
' Created by SharpDevelop.
' User: Stefan.Pendl
' Date: 30.01.2017
' Time: 16:45
' 
' To change this template use Tools | Options | Coding | Edit Standard Headers.
'

Option Strict Off
Imports System
Imports System.IO
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities

Module GetUnlockedUserOptions
    Dim theSession    As Session   = Session.GetSession()
    Dim theUFSession  As UFSession = UFSession.GetUFSession()
    Dim theUI         As UI        = UI.GetUI()
    Dim TempPath      As String    = Environment.GetEnvironmentVariable("TMP")
    Dim UGRelease     As String    = Nothing
    Dim UGFullRelease As String    = Nothing
    
    Sub Main(Args As String())
        theSession.LogFile.WriteLine("Executing ... " & _
            System.Reflection.Assembly.GetExecutingAssembly().Location)
        
        Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
        Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")
        
        UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")
        UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")
        
        System.Windows.Forms.Application.EnableVisualStyles()
        
        Dim MyUndoMark As Session.UndoMarkId = _
            theSession.SetUndoMark(Session.MarkVisibility.Visible, "GetUnlockedUserOptions")
        
        ' uncomment the following lines to check for the correct application
        'Dim AppID As Integer = UFConstants.UF_APP_NONE
        'theUFSession.UF.AskApplicationModule(AppID)
        'If AppID <> UFConstants.UF_APP_CAM Then
        '    theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
        '    Exit Sub
        'End If
        
        Dim theUnlockedOptions As New List(Of String)
        
        For Each theOption As String In theSession.OptionsManager.GetAllOptions()
            If IsOptionUnlocked(theOption) Then
                theUnlockedOptions.Add(theOption)
            End If
        Next
        
        theUnlockedOptions.TrimExcess()
        theUnlockedOptions.Sort()
        
        theSession.ListingWindow.Open()
        
        For Each theOption As String In theUnlockedOptions
            theSession.ListingWindow.WriteLine(theOption)
        Next
    End Sub
    
    Private Function IsOptionUnlocked(theOption As String) As Boolean
        If theSession.OptionsManager.IsValueSet(theOption, Options.LevelType.Site) Then
            If theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Site) Then
                Return False
            End If
        Else
            If theSession.OptionsManager.IsLevelLockedByDefault(Options.LevelType.Site) Then
                Return False
            End If
        End If
        
        If theSession.OptionsManager.IsValueSet(theOption, Options.LevelType.Group) Then
            If theSession.OptionsManager.IsValueLocked(theOption, Options.LevelType.Group) Then
                Return False
            End If
        Else
            If theSession.OptionsManager.IsLevelLockedByDefault(Options.LevelType.Group) Then
                Return False
            End If
        End If
        
        Return True
    End Function
    
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return CInt(Session.LibraryUnloadOption.Immediately)
    End Function
End Module

This now only displays the options not locked at a level above the user level.

I also tried to get the user comment, but that API method doesn't seem to return anything at any supported level.

Thanks for the heads-up Smiley Wink

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.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