iLogic Trigger on save - Chicken and the egg!

iLogic Trigger on save - Chicken and the egg!

G60Dub
Advocate Advocate
1,359 Views
7 Replies
Message 1 of 8

iLogic Trigger on save - Chicken and the egg!

G60Dub
Advocate
Advocate

I have some code that I have generated to prompt users to fill in blank iProperties on save.    I would like to implement this in our standard template files for .ipt. iam. etc. but have run into some chicken and egg difficulty.

 

Basically the code is triggered to run on a Save and checks to see if the relevant iProperties are null or whitespaced and if so displays a form until all fields are completed. 

 

However some will already see where I am going with this.   If I wish to populate the new template files with this code I would prefer the iProperties to be blank but I cannot save said template if I have the trigger enabled as it will flag up that the iProperties fields are blank

 

I may just not be seeing the wood for the trees here.  🙂

 

 

'''_________________________________________________________________________________________________
'''AUTHOR: AG
'''  DATE: 22022018
'''   REV: 0
'''_________________________________________________________________________________________________
''' Purpose: If iProperties Project, Title, Descrption or Author are blank (or null)
''' then prompt user with pop-up form To populate these requried fields. 
'''_________________________________________________________________________________________________
''' Main code begin
''' 
''' Repeat each Do loop until iProperties Project is populated in pop-up form "Required Fields Form" 
'''
Do Until String.IsNullOrWhiteSpace(Project) = False
'''Call pop-up form "Required Fields Form"
iLogicForm.Show(“Required Fields Form”, FormMode.Modal)
'''Write Project string contents to respective iProperties
Project = iProperties.Value(“Project”, “Project”)
Loop
'''
Title = iProperties.Value(“Summary”, “Title”)
Do Until String.IsNullOrWhiteSpace(Title) = False
''' '''Call pop-up form "Required Fields Form"
iLogicForm.Show(“Required Fields Form”, FormMode.Modal)
'''Write Title string contents to respective iProperties
Title = iProperties.Value(“Summary”, “Title”)
Loop
'''
Desc = iProperties.Value(“Project”, “Description”)
Do Until String.IsNullOrWhiteSpace(Desc) = False
'''Call pop-up form "Required Fields Form"
iLogicForm.Show(“Required Fields Form”, FormMode.Modal)
'''Write Description string contents to respective iProperties
Description = iProperties.Value(“Project”, “Description”)
Loop
'''
Do Until String.IsNullOrWhiteSpace(Desc) = False
'''Call pop-up form "Required Fields Form"
iLogicForm.Show(“Required Fields Form”, FormMode.Modal)
'''Write Author string contents to respective iProperties
Author = iProperties.Value(“Project”, “Description”)
Loop
'''
0 Likes
Accepted solutions (1)
1,360 Views
7 Replies
Replies (7)
Message 2 of 8

dave.cutting
Advocate
Advocate

Alan,

 

Take a look at this post. I think it offer a solution to your problem. It allows you to run external rules from any file. We have a similar set of rules to check the iProperties and it works for us.

 

http://inventortrenches.blogspot.co.uk/2011/08/built-for-speed-running-ilogic-rules.html

Dave Cutting
0 Likes
Message 3 of 8

pball
Mentor
Mentor

Try doing a right click edit iProperties from windows explorer, iLogic won't run when editing a file that way.

 

You could also setup the template to use an external iLogic script and comment out or start with a blank script, then edit the script after adding the event triggers to the templates.

 

Give those ideas a try.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 4 of 8

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @G60Dub

 

Welcome to the forum. What version of Inventor are you using?

 

I think Inventor 2018 has added some event triggers that allow you run an external rule on all files of a given type (all part files, all assembly file, etc.) 

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

Message 5 of 8

MechMachineMan
Advisor
Advisor

1. If you have Inventor 2018.2 or later, look into using prompted entries.

 

2. If you don't, just write a "cheat" piece of code to skip the rest of the code in the rule if you enter in a certain value, for when you save it initially.

ie;

 

     If FirstiPropFilledIn = "[ExcludeME]" THen: Exit Sub: End if

 


--------------------------------------
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
Message 6 of 8

G60Dub
Advocate
Advocate

Hi folks

 

I'm using Inventor 2018.3 Pro. 

 

Changing the iProperties from Windows Explorer was handy -  It's been so long since last using this method that I had completely forgotten about its' existence so many thanks for the reminder.   Smiley Happy

 

One of the suggestions above was using prompted entires in 2018.2 and onwards.   I'm familiar with using prompted entries in field text in drawings but not in the context inferred above- I've had a look at what's new in 2018.2 and cannot see anything that is pertinent to the posts above.   Smiley Frustrated 

 

 

I've compacted my code slightly but still doesn't quite run the way I expect it to.- It pops up the Menu form on first run regardless of whether the fields are populated whereas I'd prefer it to only run if any of the fields are still blank on first save.  I'm new to using VB (have only done a bit of Pascal and C++ in the past) so have no idea as to what conditional logic commands are available.  

 

While ((String.IsNullOrWhiteSpace(Project) = True Or (String.IsNullOrWhiteSpace(Title) = True) Or (String.IsNullOrWhiteSpace(Description) = True) Or (String.IsNullOrWhiteSpace(Author) = True)))
'
'Call pop-up form "Required Fields Form"
'
iLogicForm.Show("Required Fields Form", FormMode.Modal)
'
'Write Project string contents to respective iProperties
'
Project = iProperties.Value("Project", "Project")
Title = iProperties.Value("Summary", "Title")
Description = iProperties.Value("Project", "Description")
Author = iProperties.Value("Summary", "Author")
'
End While

 

 

Also handy to know there is a dedicated forum for coding!   I'll keep this post here running to its' conclusion but for cody stuff will post in the respective forum going forward. 

0 Likes
Message 7 of 8

G60Dub
Advocate
Advocate

Sorted my code - Just missed the fact that I didn't set the variable values initially and that's why the code was always running regardless of the required iProperties being populated.

0 Likes
Message 8 of 8

ankurGCK9S
Contributor
Contributor

While ((String.IsNullOrWhiteSpace(Project) = True) Or (String.IsNullOrWhiteSpace(Title) = True) Or (String.IsNullOrWhiteSpace(Description) = True) Or (String.IsNullOrWhiteSpace(Author) = True))

iLogicForm.ShowGlobal("iProperties Editor")
End While

 

Hi , I have tried above rule based on your text , but it is keep running . I just want to run the rule to pop up the "iproperties Editor" if the iprorpeties in particular file is empty  before file is saved. 

0 Likes