Inventor Customization

Reply
New Member
cidhelp
Posts: 1
Registered: ‎07-04-2011
Message 1 of 23 (1,194 Views)

Delete iLogic rule using VBA

1194 Views, 22 Replies
07-06-2011 01:12 AM

Hallo,

 

i have an iLogic rule in serveral files. Now this rule has to be deleted. This should be done with VBA. I can not find any function to delete a rule using VBA.

 

I found a function iLogicAuto.RunRuleDirect(rule), but not iLogicAuto.DeleteRule(rule) ...

 

 

I can not find any documentation for iLogic/VBA.

 

Please help me.

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 2 of 23 (1,178 Views)

Re: Delete iLogic rule using VBA

07-08-2011 06:56 AM in reply to: cidhelp

Are all the files contained in one assembly?  Do you want to delete all the rules?  If so, you can use the Delete All Rules command on the ribbon under Manage -> iLogic.

 

 Or do you want to delete only one rule, and leave other rules intact?  How many files do you need to modify?  Are they all in a single directory?

The function to delete a rule is:

iLogicAuto.DeleteRule(ByVal doc As Inventor.Document, ByVal ruleName As String)

 



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Contributor
cideonhelpdesk8693
Posts: 15
Registered: ‎04-20-2011
Message 3 of 23 (1,170 Views)

Re: Delete iLogic rule using VBA

07-08-2011 07:52 AM in reply to: MjDeck

Thank's a lot, that was easy....(for you)...  this time we have 800 files, maybe you have an idea how to find the files with the wrong rule? The files are in different directorys.

 

Regards,

 

m.giesau 

 

Employee
MjDeck
Posts: 959
Registered: ‎02-24-2009
Message 4 of 23 (1,169 Views)

Re: Delete iLogic rule using VBA

07-08-2011 07:59 AM in reply to: cideonhelpdesk8693

Does the wrong rule have the same name in all the files?

Are all the files stored in subdirectories of a single directory?

Please confirm: You don't want to delete all rules.  You only want to delete one "wrong" rule in each file.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Contributor
cideonhelpdesk8693
Posts: 15
Registered: ‎04-20-2011
Message 5 of 23 (1,162 Views)

Re: Delete iLogic rule using VBA

07-10-2011 11:32 PM in reply to: MjDeck

It is the same named rule in all files.

 

The files are stored in subdirectories.

 

I want to delete all rules.

 

m.giesau

Contributor
BrentDouglas
Posts: 18
Registered: ‎04-03-2011
Message 6 of 23 (1,155 Views)

Re: Delete iLogic rule using VBA

07-11-2011 09:32 PM in reply to: cideonhelpdesk8693

I knocked up a command line utility to do what I think you're looking for based on http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/run-all-rule-from-macro/td-p/3073630. I've attached a zip with the binary and source.

 

Usage is:

 

DeleteRules.exe path rule extension1 extension2 ...

 

e.g.

 

delete_rules_demo_usage.png

 

This deletes the rule 'rule' from all files with the extension '.ipt' and '.iam' in the folder passed in and any and all subfolders on that path.

Contributor
cideonhelpdesk8693
Posts: 15
Registered: ‎04-20-2011
Message 7 of 23 (1,141 Views)

Re: Delete iLogic rule using VBA

07-12-2011 12:54 PM in reply to: BrentDouglas

Thanks a lot, that is this was I was looking for. I tried the tool and it works fine, all files are free of this rule.

 

Regards

m.giesau

Mentor
kwilsonamerex
Posts: 258
Registered: ‎08-21-2007
Message 8 of 23 (990 Views)

Re: Delete iLogic rule using VBA

06-04-2012 11:57 AM in reply to: BrentDouglas

Hi Brent,

 

I know this is an old post but I think your post might be the solution I'm looking for. I have zero knowledge of VB outside of Inventor iLogic. I have dowloaded your files but how do I go about using them?

 

Basically I need to remove all ilogic from thousands of files. The ilogic codes can vary in name ie: "rule0", "rule1", "part_rule", "SM_rule", etc. Most are "rule0" though.

 

We use Vault Pro. The files are within different subfolders ie: file 12345 is in subfolder 12000, file 14756 is in subfolder 14000, etc.

 

Anyone that can help it would be greatly appreciated! 

Regards,
Kenny

Corsair 900D ♦ ASUS Maximus VI Extreme ♦ i7 4770k ♦ (3) GTX 780 Ti's ♦ Trident X 32GB ♦ Samsung 840 Pro ♦ WD 1TB Black ♦ SG 1TB ♦ Corsair H100i ♦ Corsair AX1200i ♦ many SP120's
PDS 2014 ♦ Vault 2014 Pro ♦ CFD 2014 ♦ Bunkspeed Pro 2014 ♦ Octane Render ♦ Certified Autodesk Inventor Professional ♦ CAD Manager/Design Engineer
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Contributor
BrentDouglas
Posts: 18
Registered: ‎04-03-2011
Message 9 of 23 (982 Views)

Re: Delete iLogic rule using VBA

06-04-2012 04:03 PM in reply to: kwilsonamerex

Hi Kenny,

 

The first thing I would do when using it is back up your files. I would also make a third copy that you run this on specifically to test that this does what you are looking for.

 

First step to use it is to unzip the files. I imagine windows has a built in tool for this, if not google should show you how to do this without too much trouble. The file you want to use is called DeleteRules.exe in the root of the zip.

 

To use it you should execute it from the command line. To do this go to Run in the start menu and type cmd. You can also get to it from Start -> Accessories -> Command Prompt

 

You should see a black screen with something line:

 

C:\Documents and Setting\Kenny>

 

From here you need to write 3 things seperated by spaces:

- The path of DeleteRules.exe that you downloaded

- The location of the folder containing the files that you want the rules deleted from

- The extension of the files you want to delete the rules from

 

For example lets say you extracted that zip to C:\Documents and Setting\Kenny\Downloads\TheZip and you keep all your inventor files that you want to delete the rules from in  C:\Documents and Setting\Kenny\Work\SomeProject and in this particular case you only want to delete the rule "rule0" from your part files (not assemblies or other inventor file) you would type:

 

C:\Documents and Setting\Kenny\Downloads\TheZip\DeleteRules.exe C:\Documents and Setting\Kenny\Work\SomeProject rule0 .ipt

 This will delete any rules called rule0 from any .ipt file in the SomeProject directory (and any sub-directories). With the Vault directory structure, it soulds like you should point it to the parent folder of the 14000, 15000, etc folders which will cover all the sub folders (This will remove the rule from every part in these folders though). If you wanted to do delete rule0 from both parts and assemblies but only from the subfolder 15000 you would use:



C:\Documents and Setting\Kenny\Downloads\TheZip\DeleteRules.exe C:\Documents and Setting\Kenny\Work\SomeProject\15000 rule0 .ipt .iam

 

For rules with different names you will need to rule that command once per rule with rule0 changed to whatever your rule is called.

 

Let me know if I have explained this ok and if this cover's what you are looking for. If this isn't what you need I might have a look at it changing it to be more appropriate tonight. I haven't used inventor since about the time I wrote the last post though so I won't promise anything.

 

Sincerely,

 

Brent Douglas

Mentor
kwilsonamerex
Posts: 258
Registered: ‎08-21-2007
Message 10 of 23 (971 Views)

Re: Delete iLogic rule using VBA

06-05-2012 06:39 AM in reply to: BrentDouglas

Wow thanks Brent!! I was able to do this using a different method and the long way around you could say but I will try yours and let you know how it goes. Thanks again!

 

Kenny

Regards,
Kenny

Corsair 900D ♦ ASUS Maximus VI Extreme ♦ i7 4770k ♦ (3) GTX 780 Ti's ♦ Trident X 32GB ♦ Samsung 840 Pro ♦ WD 1TB Black ♦ SG 1TB ♦ Corsair H100i ♦ Corsair AX1200i ♦ many SP120's
PDS 2014 ♦ Vault 2014 Pro ♦ CFD 2014 ♦ Bunkspeed Pro 2014 ♦ Octane Render ♦ Certified Autodesk Inventor Professional ♦ CAD Manager/Design Engineer
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.