Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX native set part Read only

Status
Not open for further replies.

Lars1978

Mechanical
Dec 30, 2015
327
Hi Guys,

Can I set a part read only in NX?

(I know I can do this in the windows explorer)

Lars

Lars
NX native (NX13 or NX1847)
Solid Edge ST10
Inventor
Solidworks
 
Replies continue below

Recommended for you

Newer versions of NX have an option to password protect a file; otherwise, basic file permissions for native NX are handled at the OS level.

www.nxjournaling.com
 
Unless of course if you're using Teamcenter to manage your data, then you'll have lots of options.

John R. Baker, P.E. (ret)
EX-Product 'Evangelist'
Irvine, CA
Siemens PLM:
UG/NX Museum:

The secret of life is not finding someone to live with
It's finding someone you can't live without
 
Sorry, I missed that nuance ;-)

John R. Baker, P.E. (ret)
EX-Product 'Evangelist'
Irvine, CA
Siemens PLM:
UG/NX Museum:

The secret of life is not finding someone to live with
It's finding someone you can't live without
 
Of all the things I've lost, I miss my mind the most.

John R. Baker, P.E. (ret)
EX-Product 'Evangelist'
Irvine, CA
Siemens PLM:
UG/NX Museum:

The secret of life is not finding someone to live with
It's finding someone you can't live without
 
Can you try this:

Code:
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF


Module Togggle_ReadOnly
    Sub Main()

        Dim s As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()
        Dim theUI As UI = UI.GetUI
        Dim lw As ListingWindow = s.ListingWindow()
        Dim workPart As Part = s.Parts.Work
        Dim RemUtil As RemoteUtilities = NXOpen.RemoteUtilities.GetRemoteUtilities()
        Dim FilePath As String
        Dim ufp As UFPart = ufs.Part
        Dim modified As Boolean

        ''lw.WriteLine("Work      : " & workPart.FullPath)
        FilePath = workPart.FullPath

        If RemUtil.IsFileWritable(FilePath) = True Then
            ''lw.WriteLine("File is WRITABLE")
            modified = ufp.IsModified(workPart.Tag)
            If modified Then
                If theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Question, "The Part you want to set ReadOnly is modified." & _
                                           vbCrLf & "Please save your part first if you want to keep the changes." & _
                                           vbCrLf & "Are you sure?") = 2 Then
                    theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Information, "Exit Script." & vbCrLf & "No attribute changed.")
                    Exit Sub
                End If
            End If

            RemUtil.SetFileWritable(FilePath, False)
            'check if changed
            If RemUtil.IsFileWritable(FilePath) = True Then
                ''lw.WriteLine("FAILED: File is LOCKED")
                theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Error, "Failed: File is LOCKED")
            Else
                ''lw.WriteLine("Attibute changed: File is READ-ONLY")
                theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Information, "Attibute changed: File is READ-ONLY")
            End If
        Else
            ''lw.WriteLine("File is READ-ONLY")
            RemUtil.SetFileWritable(FilePath, True)
            'check if changed
            If RemUtil.IsFileWritable(FilePath) = False Then
                ''lw.WriteLine("FAILED: File is LOCKED")
                theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Error, "Failed: File is LOCKED")
            Else
                ''lw.WriteLine("Attibute changed: File is WRITABLE")
                theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Information, "Attibute changed: File is WRITABLE")
            End If
        End If
    End Sub


End Module

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor