• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    New Member
    cidhelp
    Posts: 1
    Registered: ‎07-04-2011

    Delete iLogic rule using VBA

    507 Views, 18 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.

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    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.

    Please use plain text.
    Contributor
    cideonhelpdesk8693
    Posts: 15
    Registered: ‎04-20-2011

    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 

     

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    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.

    Please use plain text.
    Contributor
    cideonhelpdesk8693
    Posts: 15
    Registered: ‎04-20-2011

    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

    Please use plain text.
    Contributor
    BrentDouglas
    Posts: 17
    Registered: ‎04-03-2011

    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.

    Please use plain text.
    Contributor
    cideonhelpdesk8693
    Posts: 15
    Registered: ‎04-20-2011

    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

    Please use plain text.
    Distinguished Contributor
    kwilsonamerex
    Posts: 123
    Registered: ‎08-21-2007

    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

    Boxx Technologies 4920 Xtreme
    Windows 7 64-bit
    Intel Core i7 3960X @ 4.5 GHz
    32GB RAM
    NVidia Quadro 4000 - NVidia Quadro 600 - NVidia Tesla C2075
    Inventor Product Design Suite 2013 Ultimate - Vault Professional 2013 - Autodesk Simulation CFD 2013 - Bunkspeed Pro 2012
    Certified Autodesk Inventor Professional - CAD Manager/Design Engineer
    Please use plain text.
    Contributor
    BrentDouglas
    Posts: 17
    Registered: ‎04-03-2011

    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

    Please use plain text.
    Distinguished Contributor
    kwilsonamerex
    Posts: 123
    Registered: ‎08-21-2007

    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

    Boxx Technologies 4920 Xtreme
    Windows 7 64-bit
    Intel Core i7 3960X @ 4.5 GHz
    32GB RAM
    NVidia Quadro 4000 - NVidia Quadro 600 - NVidia Tesla C2075
    Inventor Product Design Suite 2013 Ultimate - Vault Professional 2013 - Autodesk Simulation CFD 2013 - Bunkspeed Pro 2012
    Certified Autodesk Inventor Professional - CAD Manager/Design Engineer
    Please use plain text.