iLogic code to trigger if excel modified date is different to last save
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
After being unsuccessful at finding a relevant solution on the internet, I'm in need of some assistance.
I'm not sure if I'm going beyond what iLogics is capable of but any advice or suggested code would be much appreciated.
1. Model Set-up
I have multiple sub-assemblies which are all driven by a single linked excel spreadsheet.
Within these assemblies, I have iLogic code written to activate / suppress certain components depending on the spreadsheet selections.
The iLogic code is triggered to run when the following events occur:
- After Open Document
- Any Model Parameter Change
2. Issue Encountered
Due to some assemblies having large amounts of code, each assembly model can take up to 2 to 3 minutes to load.
The same loading times occur again when opening the drawing sheets as well which use the same assembly file for its drawing views.
The loading times also accumulate in the General Arrangement assembly for each of the sub-assembly codes.
Therefore to remove extra unnecessary loading time, I'd like to have the iLogic code only trigger once in each assembly after there has been a change in the linked spreadsheet then never trigger again after that.
I have tried setting the iLogic to trigger only on "Any Model Parameter Change" but it has not performed how I anticipated it.
It seems that the "Any Model Parameter Change" trigger does not recognize if a change has occurred since the last save when opening an assembly. This trigger only seems to function if a change to a parameter is made after the model has finished opening.
Therefore if a change is made in the spreadsheet, saved and closed then the model opened, the trigger does not recognize a change has occurred.
I also require the iLogic code to trigger straight after opening the model otherwise I may get some unresolved constraints and/or lost geometry until the iLogic is run.
3. Desired Solution Yet To Be Found
Ideally, I'd like to write some iLogic code where it does the following:
a. Reads the excel file's properties for the last modified date and time stamp.
b. Compares this date against the inventor assembly's custom iproperty called Excel_Save_Date.
c. If the excel date and the custom iproperty date match, then the iLogic code does not run.
d. But if the excel date and the custom iproperty date don't match, then the iLogic code does run to activate / suppress certain components.
e. The last part of the iLogic code then updates the custom iproperty called Excel_Save_Date to match the excel file's last modified date and time stamp.
I am proficient at writing basic iLogic code such as If...Then statements and looking up iproperties, but the more advance coding (such as pulling in properties from other external files) I'm still learning on the run.
I have tried experimenting in writing the above desired code but have not come close enough to even warrant posting here.
Therefore any assistance would be very much appreciated.
Regards,
Kurt.