Hi,
How to get all Inventor drawing sheets fit on PC screen. Example iLogic code below makes only Gasket:3 to fit the screen (always last one in the code chaine) . Nothing happens with sheets :1 and :2 .
ActiveSheet = ThisDrawing.Sheet("MainAssembly:1") ThisApplication.ActiveView.Fit ActiveSheet = ThisDrawing.Sheet("WeldAssembly:2") ThisApplication.ActiveView.Fit ActiveSheet = ThisDrawing.Sheet("Gasket:3") ThisApplication.ActiveView.Fit
Hi,
In the user interface as well, there can only be one sheet active at a time, so I don't think there is a way around that through the API.
Cheers,
@axa-61 and anyone else interested, below is some code that I just put together which will zoom all sheets in a drawing to the Zoom-Extents setting.
It gets around the issue @adam.nagy pointed out by actually activating each sheet one-by-one and zooming all. It then returns you to your previously-active sheet.
Because it has to activate each sheet, any sheets which take a long time to load or need to be updated will slow it down. But other than that, it's very snappy.
"Zoom Extents All Sheets" code:
Sub Main() 'Make sure the active document is a Drawing If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then MessageBox.Show("The active document is not a drawing. The rule will now terminate.", "Sketch Symbol Auto-Numbering",MessageBoxButtons.OK,MessageBoxIcon.Error) Exit Sub End If ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet 'Set a reference to the current Active sheet so we can re-activate it after the rule is done Dim myActiveSheet As Sheet myActiveSheet = oDrawDoc.ActiveSheet 'Start a transaction Call ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Zoom Extents All Sheets") 'Progress bar oMessage = "Zooming Extents on All Sheets..." Dim SheetCount As Integer SheetCount = oDrawDoc.Sheets.Count Dim oProgressBar As Inventor.ProgressBar oProgressBar = ThisApplication.CreateProgressBar(False,SheetCount,oMessage) 'Create sheet counter variable Dim iSheetCount As Integer iSheetCount=0 On Error Goto ErrorTrapper 'Iterate through each sheet and zoom to the sheet extents For Each oSheet In oDrawDoc.Sheets 'Get the current sheet number iSheetCount=iSheetCount+1 'Activate the current sheet oSheet.Activate 'Update the progress bar to reflect which sheet is being operated on oProgressBar.Message = ("Processing Sheet " & iSheetCount & " of " & SheetCount & "...") oProgressBar.UpdateProgress 'Zoom to the sheet extents ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute Next 'Sheet RuleExit: 'Re-activate the originally active sheet myActiveSheet.Activate 'Close the progress bar oProgressBar.Close 'End the transaction ThisApplication.TransactionManager.EndTransaction '] Exit Sub ErrorTrapper: MessageBox.Show("There was an error processing sheet " & iSheetCount & ". The rule will now terminate.", "Zoom Extents All Sheets",MessageBoxButtons.OK,MessageBoxIcon.Error) Goto RuleExit End Sub
This works great. I'm using it now in a slightly different application and I'm running into I minor issue. I am zooming using the AppZoomallCmd and then exporting an image using SaveAsBitmap. However, the image shows the background around the sheet like a thick border. I tested several ways to try to remove the "border" and the only success I've had was using a zoom window manually and select the corners of the sheet to zoom in further before export. Is there a way to zoom in further?
You almost certainly need to use the view via Application.Views
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-68F79E38-F7BD-4700-A08E-6E8E928C4825
Whether its tweaking the camera, or just the view width etc. is something you will have to figure out.
Another alternative could be to use the code to activate the Zoom to window command, but this would then require the user to manually select the window size.