iLogic code to trigger if excel modified date is different to last save

iLogic code to trigger if excel modified date is different to last save

kwalker1
Enthusiast Enthusiast
547 Views
1 Reply
Message 1 of 2

iLogic code to trigger if excel modified date is different to last save

kwalker1
Enthusiast
Enthusiast

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.

0 Likes
548 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor

I would suggest expanding your knowledge base, as this will become a Visual Basic Program rather than simple iLogic as you need to access external files.

They are very similiar as iLogic is based off of vb.net.

 

Some additional resources to look into are googling "msdn vb.net" and using that reference.

 

I would think that you are either going to want to look into System.IO for accessing windows file information or maybe something more specific to excel.

 

Googling stuff that is independent of inventor but taggin it with vb.net will often lead to a lot of results.

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes