Hi,
Interesting question! here's my attempt to make it work
Not tested yet (no time for that currently), but hopefully you'll now have some basis to start with
The idea: you place both this rule and the script (wich I assume is a separate rule although an external rule should work as well) in a document (ipt, iam, idw doesn't matter), it will loop through all of them: open them: run the script: and close them
be sure to check out all files first! (should be possible automaticly in inventor 2024 but that's a whole different problem 😉 )
I added 2 ways to select all the documents, so choose the one you wish or add your own 😉
(hopefully it works lol)
I'm very interested to see your script for making a bitmap file, if you are interested in sharing it
happy coding!
Sub main
Dim docs As List(Of String)
'get path of all files
docs = populatedocs1
'docs = populatedocs2
'loop over all paths in doc
For Each doc In docs
Call run_rule_in_docs(doc)
Next
End Sub
Function populatedocs1 As List(Of String)
'adaptation of code from: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/how-do-i-run-an-external-rule-on-all-files-in-a-folder/td-p/10496739
Dim Folder As New IO.DirectoryInfo("C:\TEMP")
For Each File As IO.FileInfo In Folder.GetFiles("*.ipt",IO.SearchOption.AllDirectories)
If File.FullName.Contains("OldVersions") = False Then
populatedocs1.Add(File.FullName)
End If
Next
End Function
Function populatedocs2 As List (Of String)
populatedocs2.Add("C:\TEMP\doc1.ipt")
populatedocs2.Add("C:\TEMP\doc2.ipt")
populatedocs2.Add("C:\TEMP\doc3.ipt")
populatedocs2.Add("C:\TEMP\doc4.ipt")
populatedocs2.Add("C:\TEMP\doc5.ipt")
populatedocs2.Add("C:\TEMP\doc6.ipt")
populatedocs2.Add("C:\TEMP\doc7.ipt")
Return populatedocs2
End Function
Sub run_rule_in_docs(sFilePath As String)
'adaptation of code from: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/run-ilogic-rule-from-an-external-part-file/m-p/6026688#M61524
'name of ilogic rule
Dim oRuleName As String = "TestRule"
'open the file invisibly
oFile = ThisApplication.Documents.Open(sFilePath, False)
'define the ilogicAutomation
Dim iLogicAuto As Object
iLogicAuto = iLogicVb.Automation
'get the rule
Dim oRule As Object
oRule = iLogicAuto.GetRule(oFile, oRuleName)
'run the rule
iLogicAuto.RunRuleDirect(oRule)
'close the file
oFile.Close
End Sub