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:
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!
Solved! Go to Solution.
Solved by JelteDeJong. Go to Solution.
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.
Blog: hjalte.nl - github.com
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.
👍
Can't find what you're looking for? Ask the community or share your knowledge.