Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 532

Method to get the age and name of an ETO Member file

$
0
0

By Wayne Brill

You may want to get the name and age of a member file used by an Inventor Engineer-To-Order adopted part. Here are a couple of methods that show how this can be done. Notice it uses the default rule memberPathName to get the path to the member file. .NET System.IO methods are used to get the difference between the current time and the last time the member file was written to.

Note: If you use cacheFileName to create your own naming scheme for member files you would need to update this example to get the get the name of the member file. The cacheFileName gives you the filename. The memberPathName ensures that the file specified by cacheFileName is created. Depending on the scenario, one of these two Rules can be used.

Methods from an ETO Design:

Method IPTFileAgeInFullDays( p As Part) As Integer

      If Not p.IsKindOf?( :IvAdoptedPart) Then _

       Error( "Wrong Part", "IvAdoptedPart expected")

 

      Dim memberPathname As String = p.memberPathname

      Dim  memberCacheFileName As String = p.cacheFileName

      printValue(memberCacheFileName)

      printValue(memberPathName)

 

      Return FileAgeInFullDays( memberPathname)

 

End Method

 

'This Method returns the age of the existing file

'(based on last modification time), In full days :

 

Method FileAgeInFullDays( fileName As String) As Integer

      If Not system.IO.File.Exists(fileName) _

      Then Error("Error", "File "  + fileName + _

      " does not exist.")

 

      Dim lwt = system.IO.File.GetLastWriteTime( fileName)

      Dim now = system.Datetime.Now

      Dim span = now.Subtract( lwt)

      Return floor(span.TotalDays)

End Method


Viewing all articles
Browse latest Browse all 532

Trending Articles