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: 

run rule on all open parts

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
cadman777
1058 Views, 2 Replies

run rule on all open parts

Dear Sirs,

I've been trying for the better part of today to get a rule to run on all open parts using this code:

'Run External iLogic rule on all opened documents to EXPORT ALL DXF FLATPATTERNS
Public Sub Internal_iLogic()
Dim addIn As ApplicationAddIn
Dim addIns As ApplicationAddIns
Set addIns = ThisApplication.ApplicationAddIns
    For Each addIn In addIns
        If InStr(addIn.DisplayName, "iLogic") > 0 Then
                        addIn.Activate
            Dim iLogicAuto As Object
            Set iLogicAuto = addIn.Automation
            Exit For
        End If
    Next
 
  Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
  If oDoc Is Nothing Then
    MsgBox "Missing Inventor Document"
    Exit Sub
  End If
Set oDoc = ThisApplication.ActiveDocument
iLogicAuto.RunExternalRule oDoc, "DXF_EXPORT_FLATPATTERN_OPEN_PART-10" 'for external rule
'oDoc.Activate
Next
End Sub

I got that code off this forum post:

https://forums.autodesk.com/t5/inventor-customization/execute-ilogic-for-all-open-documents/m-p/7713...

It's philip.g's code at the end of the thread.

The thing is, it won't operate on every open part doc.

It only works on the first part doc.

The open docs are sheetmetal parts.

The iLogic rule it's calling works perfect when manually 'Run' one at a time.

I read in a post (which I can't find, by MDeck) about changing the document call, but can't recall what he said or what to try next.

I'd be very grateful if someone can clue me in on how to get this to work.

This is VBA, and I'm just beginnig to get the hang of hacking together iLogic.

So VBA is stepping out of my 'comfort zone'.

TIA!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
2 REPLIES 2
Message 2 of 3
JelteDeJong
in reply to: cadman777

the biggest problem i see with your code is that the line:

"Set oDoc = ThisApplication.ActiveDocument"

in the for each loop. try this iLogic rule.

Dim addIn As ApplicationAddIn
Dim addIns As ApplicationAddIns = ThisApplication.ApplicationAddIns
Dim iLogicAuto
For Each addIn In addIns
    If InStr(addIn.DisplayName, "iLogic") > 0 Then
        iLogicAuto = addIn.Automation
        Exit For
    End If
Next

For Each oDoc As Document In ThisApplication.Documents.VisibleDocuments
    oDoc.Activate()
    iLogicAuto.RunExternalRule(oDoc, "DXF_EXPORT_FLATPATTERN_OPEN_PART-10")
Next

(i also removed some other lines that didnt do much.)

Jelte de Jong
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


Blog: hjalte.nl - github.com

Message 3 of 3
cadman777
in reply to: JelteDeJong

Jelte,

Perfect!

Thanx for doing this for me!

Your code is a valuable lesson learned.

Thought you had to use VBA to do this.

Also, the simpler the better.

This is an excellent template for many other rules that can run on all open docs.

👍

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report