Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete iLogic rule using VBA

22 REPLIES 22
Reply
Message 1 of 23
cidhelp
5115 Views, 22 Replies

Delete iLogic rule using VBA

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.

22 REPLIES 22
Message 2 of 23
MjDeck
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
Autodesk, Inc.

Message 3 of 23
cideonhelpdesk8693
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 

 

Message 4 of 23
MjDeck
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
Autodesk, Inc.

Message 5 of 23
cideonhelpdesk8693
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

Message 6 of 23

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.

Message 7 of 23

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

Message 8 of 23

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
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 9 of 23

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

Message 10 of 23

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
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 11 of 23

Brent,

 

Works like a charm and exactly what I was looking for!

 

Thanks again and best regards,

 

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 12 of 23

Brent,

 

Does your app only work with model files (ipt & iam)? I tried to run it on dwg's and idw's but it doesn't like it. The object is only an inventor model? TIA

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 13 of 23

Brent, I keep getting an unhandled exception rule in cmd prompt when trying to rule on .iam, .dwg and .idw files. Works like a charm on .ipt files though! Getting there and thanks for your help on this!!

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 14 of 23

Sorry it's taken so long to get back to you, work has been hectic in the last 2 weeks. I'll try and look at it over the weekend. I probably only tested it on .ipt files when I wrote it. Can you post the stack trace?

 

Brent

Message 15 of 23

Hey Brent, Sorry its taken me a bit to reply. Been hectic here at work with some other issues. Attached is a text file that I pasted the errors I got when trying to use it on an iam, dwg and idw. Thanks so much for helping me on this! If you're ever in central Alabama I owe you a beer... or two lol

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 16 of 23

It should work with idw and dwg's now. I changed the way it takes parameterst to make it a bi more flexible. Now you can specify multiple extensions, rules and paths. e.g. This:

 

C:\Path\To\Unzipped\Folder> ./DeleteRules.exe -t ipt -t dwg -r "First Rule" -r SecondRule C:\Some\Path\To\Files C:\Some\Other\Path\To\More\Files

Will delete both specified rules from all .ipt and .dwg files in both paths. I also changed it to ignore the OldVersions folder that Inventor saves previous versions in.

 

I would try this out on a test copy of your files before running it over your production files.

 

I'm glad to be of assistance Kenny, let me know if it works for you.

 

Brent

Message 17 of 23

Brent,

 

Thanks for chiming in and editing your program for me.

 

I replaced the "deleterules.exe" of my old one with your new one in the root of all my files I need to edit.

To save time we have a Windows Command Script to make it a simple process to "kick-off" your program.

However when I replaced the deleterules.exe with the new one and clicked on the WCscript, it only shows this (see attached).

In the past it would simply run thru the files. Am I doing something wrong?

 

Again thanks so much for this help. We're gettng there!

 

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 18 of 23

I had changed the way you passed parameters to it so it should be faster over a large amount of files (it only has to open each file once rather than once per rule). You specify each file extension as -t ipt or -t dwg and each rule as -r SomeRule. I have attached another copy that should work with the script you had already written though.

 

Brent

Message 19 of 23
kwilson_design
in reply to: cidhelp

Brent, Thanks again for chiming in! We've ran it but found one issue. When running it on .dwg files it will bomb out when it "sees" the OldVersions folder. So we've added a little sumin to remove the folder prior to running the rule against dwg files. Take a look :smileyhappy:

 

rmdir "C:\test folder\01000\OldVersions" /S /Q

deleterules "C:\test folder\01000" "cheese puff" -t .dwg

rmdir "C:\test folder\01000\OldVersions" /S /Q

deleterules "C:\test folder\01000" "rule 0" -t .dwg

pause

 

Yes we liike to have fun naming files and folders in the test env :smileyhappy:

 

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 20 of 23
twinz3950
in reply to: kwilson_design

This is an old post, but I have been using the DeletRules.exe form this post and it has worked great; however we have switched to Inventor Pro. 2014 and when I try to  execute the rule it works with .ipt files but errors out when use it for .iam files. Can some one chime in with help on this thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report