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

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

Comments

One response to “Method to get the age and name of an ETO Member file”

  1. Hello,
    Is there any method to write set or define the cacheFileName within the child rule of the generated ipt ?
    Thank you / Regards
    Timo

Leave a Reply to THSULZERCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading