iLogic rule issue after Inventor update

iLogic rule issue after Inventor update

Anonymous
Not applicable
1,049 Views
5 Replies
Message 1 of 6

iLogic rule issue after Inventor update

Anonymous
Not applicable

We recently updated to Inventor 2018, and with the update our IT department added a new server. We have an iLogic rule embedded in our drawing template that does some checks on the file before closing. The iLogic rule references an external rule, so the path is embedded locally into every drawing we have (1000s of drawings).

 

I'm wondering if there is a way to create an iLogic rule to edit another iLogic rule. The editing rule would simply find string xyz and replace with string abc.

 

Anybody have any suggestions?

 

Thanks,


Phil

0 Likes
1,050 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor

With 2018.1, you cans set global triggers. Including those that run on drawing documents specifically.

 

I suggest you just remove the event triggers stored in the documents and move it all to a single global event trigger.

 

If you search around for MegaJerk's Code Injector, it should be able to provide some help for you.


--------------------------------------
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 3 of 6

rhasell
Advisor
Advisor

Hi

 

If it is possible, it may be a good time to move the rule to an external rule as well.

 

As you and the business grows, the rules change, embedded rules are much harder to mange.

 

Reg
2026.1
0 Likes
Message 4 of 6

Martin-Winkler-Consulting
Advisor
Advisor

Hi Phil

here are VBA Code Snippets to change the complete content of a rule.

Simply save the new Content in a .txt File and Run the snippets from VBA Macro or with InventorVb.RunMacro("projectName", "moduleName", "macroName") from another iLogic Rule.

 

Sub ChangeText_iLogicRule()
    Dim iLogicAuto As Object
    Set iLogicAuto = GetiLogicAddin(ThisApplication)
    
    If (iLogicAuto Is Nothing) Then Exit Sub
    Dim curDoc As Document
    Set curDoc = ThisApplication.ActiveDocument
    
    Dim rule As Object
    Dim rules As Object
    Set rules = iLogicAuto.rules(curDoc)
    If (Not rules Is Nothing) Then
      For Each rule In rules
        If rule.Name = "Rule" Then  'Change to Rule Name you want to edit
         'rule.Name = "NewRuleName" 'Here you can change the Rule Name if required
         rule.Text = ReadTextFile("C:\Users\Public\NewRule.txt") 
'edit the path to the NewRule.txt
        End If
      Next
    End If
End Sub

Public Function ReadTextFile(vPath As String) As String
'Code to read file until finished
Dim X As String
Dim vText As String
Open vPath For Input As #1
Do While Not EOF(1)
  Line Input #1, X
  ReadTextFile = ReadTextFile & vbCrLf & X
Loop
'Debug.Print ReadTextFile
Close
End Function

Perhaps this is what you are looking for.

 

 

 

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Message 5 of 6

Anonymous
Not applicable

So I copied the above code, made the alternations required for my environment, and I get errors stating "Get and Let are no longer supported" and now i'm stuck.

 

Any suggestions?

 

Thanks!

Message 6 of 6

Martin-Winkler-Consulting
Advisor
Advisor

HI @Anonymous

did you copied the code into an iLogic Rule ore into a vba module?

The code is written for using in a vba module.

 

 

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes