Message 1 of 11
(Need help) Traversing open tabs with iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to make a program that prints all the open tabs in inventor from left to right. My program is failing to print duplicate tabs. Any help or advice would be greatly appreciated.
printAll program:
Sub main()
Dim i As Integer = 1
For Each oDrwDoc In ThisApplication.Documents
If oDrwDoc.DocumentType = kDrawingDocumentObject Then
Dim oDrgPrintMgr As DrawingPrintManager
oDrgPrintMgr = oDrwDoc.PrintManager
'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = kCustomScale
oDrgPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale
'oDrgPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeLedger
'oDrgPrintMgr.PaperSize = 14338
oDrgPrintMgr.PrintRange = kPrintCurrentSheet
'oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.AllColorsAsBlack = True
oDrgPrintMgr.SubmitPrint
End If
Next
End Sub
I made a separate program that opens all drawings of parts and sub assemblies found in a parts list of a top level assembly and its sub assemblies parts lists. In my example we have a LH and RH sub assembly which both contain an identical part. My "openAll" program checks to see if a drawing is already open and if so, it creates a new window of that drawing.
Snippet from openAll program that makes new windows of duplicate drawings:
'we need to check if drawing is already open and if it is not then open it
'if already open then we call CopyTab()
'source: https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-check-if-drawing-file-is-open/td-p/10243425
Sub DupeCheck()
Dim oDoc As Document = ThisApplication.ActiveDocument
TopLVL = RuleArguments("Og")
ThisName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName)
'MsgBox(ThisName & " compared to " & TopLVL)
For Each Doc In ThisApplication.Documents 'check if there is an open IDW with matching doc name
Dim oDC As Document = Doc
If oDC.DocumentType = DocumentTypeEnum.kDrawingDocumentObject And System.IO.Path.GetFileNameWithoutExtension(oDC.FullDocumentName) = ThisName And TopLVL <> ThisName
oDC.Activate
Call CopyTab() 'copy IDW window to new window
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 'if duped doc is an assy we get recursive
oDoc.Close(True) 'close the reference doc
Call Main()
Else
oDoc.Close(True) 'close the reference doc
End If
Exit Sub
End If
Next
If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 'If active doc=Iam, do recursion
iLogicVb.RunExternalRule("C:\Users\Mw\Desktop\Inventor Macros\OpenVaultIDW") 'opens matching IDW and closes refDoc
If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
Call PartsListCheck() 'check if assy drawing has parts list
Else If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
'MsgBox("close iam")
ThisApplication.ActiveDocument.Close(True)
End If
Else If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
iLogicVb.RunExternalRule("C:\Users\Mw\Desktop\Inventor Macros\OpenVaultIDW") 'opens matching IDW and closes refDoc
If ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
'MsgBox("close ipt")
ThisApplication.ActiveDocument.Close(True)
End If
End If
End Sub
'copy IDW window to new window
'source: https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-DB8C7D03-9B57-403B-885F-2F2180CBD45A
Sub CopyTab()
'MsgBox("CopyTab Called")
Dim oDoc2 As Document = ThisApplication.ActiveDocument
Dim oView1 As View
oView1 = oDoc2.Views(1)
Dim oViewTab1 As ViewTab
oViewTab1 = oView1.ViewTab
Dim oView2 As View
oView2 = oDoc2.Views.Add
End Sub