Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
JohnRBaker said:Unless of course if you're using Teamcenter to manage your data, then you'll have lots of options.
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