Hi guys,
I wrote a script that changes the file attribute of a part to readonly. And I want to add a check if a part is modified. After searching the help I found "NXOpen.UF ► UFPart ► IsModified(Tag)".
But I don't know how to call the Ismodified-function.
Please help!
Thanks
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections
Imports System.Threading
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Module ReadOnly_ON
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
Dim modified As Boolean
''lw.WriteLine("Work : " & workPart.FullPath)
FilePath = workPart.FullPath
modified = ufp.IsModified(workPart.Tag)
If modified Then
lw.WriteLine("modified")
End If
If RemUtil.IsFileWritable(FilePath) = True Then
''lw.WriteLine("File is WRITABLE")
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 already READ-ONLY")
theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Warning, "File is already READ-ONLY")
End If
End Sub
End Module
I wrote a script that changes the file attribute of a part to readonly. And I want to add a check if a part is modified. After searching the help I found "NXOpen.UF ► UFPart ► IsModified(Tag)".
But I don't know how to call the Ismodified-function.
Please help!
Thanks
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections
Imports System.Threading
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies
Module ReadOnly_ON
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
Dim modified As Boolean
''lw.WriteLine("Work : " & workPart.FullPath)
FilePath = workPart.FullPath
modified = ufp.IsModified(workPart.Tag)
If modified Then
lw.WriteLine("modified")
End If
If RemUtil.IsFileWritable(FilePath) = True Then
''lw.WriteLine("File is WRITABLE")
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 already READ-ONLY")
theUI.NXMessageBox.Show(workPart.Leaf & ".prt", NXMessageBox.DialogType.Warning, "File is already READ-ONLY")
End If
End Sub
End Module