<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get a Grey Background with adjusted View-size, when more than one Document is open. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222293#M181389</link>
    <description>&lt;P&gt;I have the following Problem:&lt;/P&gt;&lt;P&gt;If I adjust the active view with the Code below with only one document open, it works and i have a grey background with a clear difference to the adjusted view. But if more than one document is open there is always a remaining blue background of the same or another document without a clear difference to the adjusted view. How can I get the other documents to stay minimized and the background to stay gray like if only one Document is open?&lt;/P&gt;&lt;P&gt;This is the Code I use:&lt;/P&gt;&lt;P&gt;(VisualBasic)&lt;/P&gt;&lt;P&gt;Public Sub subWNQuadrat()&lt;BR /&gt;'go on only with an active document&lt;BR /&gt;Set oWNDoc = ThisApplication.ActiveDocument&lt;BR /&gt;Dim oWNview As View&lt;BR /&gt;Dim strWNMeldung As String&lt;BR /&gt;If (oWNDoc Is Nothing) Then&lt;BR /&gt;strWNMeldung = "This Makro only functions with open documents! "&lt;BR /&gt;MsgBox strWNMeldung, vbCritical&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;ThisApplication.ScreenUpdating = False&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kNormalWindow&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kMaximize&lt;BR /&gt;'ask for length&lt;BR /&gt;Dim lgWnt As Long&lt;BR /&gt;Dim lgWnl As Long&lt;BR /&gt;Dim lgWnh As Long&lt;BR /&gt;Dim lgWnw As Long&lt;BR /&gt;Call ThisApplication.ActiveView.GetWindowExtents(lgWnt, lgWnl, lgWnh, lgWnw)&lt;BR /&gt;'set all to greater length&lt;BR /&gt;If lgWnw &amp;gt;= lgWnh Then&lt;BR /&gt;ThisApplication.ActiveView.width = ThisApplication.ActiveView.height&lt;BR /&gt;Else&lt;BR /&gt;ThisApplication.ActiveView.height = ThisApplication.ActiveView.width&lt;BR /&gt;End If&lt;BR /&gt;ThisApplication.ScreenUpdating = True&lt;BR /&gt;ThisApplication.ActiveView.Update&lt;BR /&gt;If ThisApplication.Views.Count = 1 Then&lt;BR /&gt;subWNAppExtents&lt;BR /&gt;Else&lt;BR /&gt;For Each oWNview In ThisApplication.Views&lt;BR /&gt;If Not (oWNview = ThisApplication.ActiveView) Then&lt;BR /&gt;oWNview.WindowState = kMinimize&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;BR /&gt;'debug.print "Resize"&lt;BR /&gt;'Call subWNshowAkiveViewSize&lt;BR /&gt;End Sub&lt;BR /&gt;Public Sub subWNVoll()&lt;BR /&gt;Dim strWNMeldung As String&lt;/P&gt;&lt;P&gt;Set oWNDoc = ThisApplication.ActiveDocument&lt;BR /&gt;If (oWNDoc Is Nothing) Then&lt;BR /&gt;strWNMeldung = "This Makro only functions with open documents! "&lt;BR /&gt;MsgBox strWNMeldung, vbCritical&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;'Fenster Maximieren&lt;BR /&gt;If ThisApplication.Views.Count = 1 Then&lt;BR /&gt;Call subWNViewMaxEinView&lt;BR /&gt;Else&lt;/P&gt;&lt;P&gt;ThisApplication.ScreenUpdating = False&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kNormalWindow&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kMaximize&lt;BR /&gt;ThisApplication.ScreenUpdating = True&lt;BR /&gt;ThisApplication.ActiveView.Update&lt;BR /&gt;End If&lt;BR /&gt;End Sub&lt;BR /&gt;Sub subWNAppExtents()&lt;BR /&gt;'Aktuelle Größe Dokumentfenster abfragen&lt;BR /&gt;Dim lgWnt As Long&lt;BR /&gt;Dim lgWnl As Long&lt;BR /&gt;Dim lgWnh As Long&lt;BR /&gt;Dim lgWnw As Long&lt;BR /&gt;Call ThisApplication.GetAppFrameExtents(lgWnt, lgWnl, lgWnh, lgWnw)&lt;/P&gt;&lt;P&gt;'move to destination&lt;BR /&gt;Call ThisApplication.Move(lgWnt, lgWnl, lgWnh, lgWnw)&lt;BR /&gt;End Sub&lt;BR /&gt;Sub subWNViewMaxEinView()&lt;BR /&gt;ThisApplication.ActiveView.Visible = False&lt;BR /&gt;Call subWNAppExtents&lt;BR /&gt;Call ThisApplication.Views.Item(1).Activate&lt;BR /&gt;End Sub&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2026 14:15:32 GMT</pubDate>
    <dc:creator>benedikt_seitzLXJD2</dc:creator>
    <dc:date>2026-08-04T14:15:32Z</dc:date>
    <item>
      <title>Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222293#M181389</link>
      <description>&lt;P&gt;I have the following Problem:&lt;/P&gt;&lt;P&gt;If I adjust the active view with the Code below with only one document open, it works and i have a grey background with a clear difference to the adjusted view. But if more than one document is open there is always a remaining blue background of the same or another document without a clear difference to the adjusted view. How can I get the other documents to stay minimized and the background to stay gray like if only one Document is open?&lt;/P&gt;&lt;P&gt;This is the Code I use:&lt;/P&gt;&lt;P&gt;(VisualBasic)&lt;/P&gt;&lt;P&gt;Public Sub subWNQuadrat()&lt;BR /&gt;'go on only with an active document&lt;BR /&gt;Set oWNDoc = ThisApplication.ActiveDocument&lt;BR /&gt;Dim oWNview As View&lt;BR /&gt;Dim strWNMeldung As String&lt;BR /&gt;If (oWNDoc Is Nothing) Then&lt;BR /&gt;strWNMeldung = "This Makro only functions with open documents! "&lt;BR /&gt;MsgBox strWNMeldung, vbCritical&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;ThisApplication.ScreenUpdating = False&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kNormalWindow&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kMaximize&lt;BR /&gt;'ask for length&lt;BR /&gt;Dim lgWnt As Long&lt;BR /&gt;Dim lgWnl As Long&lt;BR /&gt;Dim lgWnh As Long&lt;BR /&gt;Dim lgWnw As Long&lt;BR /&gt;Call ThisApplication.ActiveView.GetWindowExtents(lgWnt, lgWnl, lgWnh, lgWnw)&lt;BR /&gt;'set all to greater length&lt;BR /&gt;If lgWnw &amp;gt;= lgWnh Then&lt;BR /&gt;ThisApplication.ActiveView.width = ThisApplication.ActiveView.height&lt;BR /&gt;Else&lt;BR /&gt;ThisApplication.ActiveView.height = ThisApplication.ActiveView.width&lt;BR /&gt;End If&lt;BR /&gt;ThisApplication.ScreenUpdating = True&lt;BR /&gt;ThisApplication.ActiveView.Update&lt;BR /&gt;If ThisApplication.Views.Count = 1 Then&lt;BR /&gt;subWNAppExtents&lt;BR /&gt;Else&lt;BR /&gt;For Each oWNview In ThisApplication.Views&lt;BR /&gt;If Not (oWNview = ThisApplication.ActiveView) Then&lt;BR /&gt;oWNview.WindowState = kMinimize&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;End If&lt;BR /&gt;'debug.print "Resize"&lt;BR /&gt;'Call subWNshowAkiveViewSize&lt;BR /&gt;End Sub&lt;BR /&gt;Public Sub subWNVoll()&lt;BR /&gt;Dim strWNMeldung As String&lt;/P&gt;&lt;P&gt;Set oWNDoc = ThisApplication.ActiveDocument&lt;BR /&gt;If (oWNDoc Is Nothing) Then&lt;BR /&gt;strWNMeldung = "This Makro only functions with open documents! "&lt;BR /&gt;MsgBox strWNMeldung, vbCritical&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;'Fenster Maximieren&lt;BR /&gt;If ThisApplication.Views.Count = 1 Then&lt;BR /&gt;Call subWNViewMaxEinView&lt;BR /&gt;Else&lt;/P&gt;&lt;P&gt;ThisApplication.ScreenUpdating = False&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kNormalWindow&lt;BR /&gt;ThisApplication.ActiveView.WindowState = kMaximize&lt;BR /&gt;ThisApplication.ScreenUpdating = True&lt;BR /&gt;ThisApplication.ActiveView.Update&lt;BR /&gt;End If&lt;BR /&gt;End Sub&lt;BR /&gt;Sub subWNAppExtents()&lt;BR /&gt;'Aktuelle Größe Dokumentfenster abfragen&lt;BR /&gt;Dim lgWnt As Long&lt;BR /&gt;Dim lgWnl As Long&lt;BR /&gt;Dim lgWnh As Long&lt;BR /&gt;Dim lgWnw As Long&lt;BR /&gt;Call ThisApplication.GetAppFrameExtents(lgWnt, lgWnl, lgWnh, lgWnw)&lt;/P&gt;&lt;P&gt;'move to destination&lt;BR /&gt;Call ThisApplication.Move(lgWnt, lgWnl, lgWnh, lgWnw)&lt;BR /&gt;End Sub&lt;BR /&gt;Sub subWNViewMaxEinView()&lt;BR /&gt;ThisApplication.ActiveView.Visible = False&lt;BR /&gt;Call subWNAppExtents&lt;BR /&gt;Call ThisApplication.Views.Item(1).Activate&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2026 14:15:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222293#M181389</guid>
      <dc:creator>benedikt_seitzLXJD2</dc:creator>
      <dc:date>2026-08-04T14:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222443#M181394</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/19360459"&gt;@benedikt_seitzLXJD2&lt;/a&gt;.&amp;nbsp; What is the purpose or goal of your code above?&amp;nbsp; Maybe if we better understand what you are trying to achieve with it, it will help us understand how to fix it the way you want.&lt;/P&gt;
&lt;P&gt;At first glance, I see two things which may be a problem.&amp;nbsp; The first is near the start of the code at the following line:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oWNview As View&lt;/LI-CODE&gt;
&lt;P&gt;I would change that to this:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oWNview As Inventor.View&lt;/LI-CODE&gt;
&lt;P&gt;...to make sure your code understands that it is supposed to represent the type of View defined in Inventor's API (&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=GUID-View" target="_blank" rel="noopener"&gt;Inventor.View&lt;/A&gt;) and not the&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.view" target="_blank" rel="noopener"&gt;System.Windows.Forms.View&lt;/A&gt;, which is an Enum.&amp;nbsp; There are several Types of objects which have 'common' names among Inventor's API, the greater Visual Basic coding language, and other referenced API's, so sometimes we should be a bit more specific about which one we are referring to, or the code reader can get confused.&lt;/P&gt;
&lt;P&gt;The next thing I see is in the following lines of code:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;For Each oWNview In ThisApplication.Views
If Not (oWNview = ThisApplication.ActiveView) Then&lt;/LI-CODE&gt;
&lt;P&gt;I believe you should change the equals sign (=) to the 'Is' operator, because you are comparing 2 objects, not two numerical values or text Strings.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2026 16:29:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222443#M181394</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2026-08-04T16:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222997#M181400</link>
      <description>&lt;P&gt;Thanks for the Reply.&lt;/P&gt;&lt;P&gt;The code should set the size of the view to a square, as big as possible. The rest of the window should be colored in another way so that this square is clearly visable and can be separated from the rest of the window with the human eye. The general purpose is to be able to make a Screenshot of the window and to cut out evreything exept&amp;nbsp; the square because of the clear difference.&lt;/P&gt;&lt;P&gt;I changed the parts you mentioned and it worked for a second to get a square with the rest of the window having the standart grey background, but then it changed back to the full size.&lt;/P&gt;&lt;P&gt;When I repeat the code a new view is generated in the shape of the square but the original view is still in the background of the window and visable outside the square.&lt;/P&gt;&lt;P&gt;When I move the mouse the original view is replaced by the other opened document and there is no clear difference, so the border of the square can´t be seen because both documents have a blue background.&lt;/P&gt;&lt;P&gt;If I reset the view to its original size there is the one second result one time again and the rest is like described before.&lt;/P&gt;&lt;P&gt;If I go through the code step by step at first&amp;nbsp;a new view is generated in the shape of the square but the original view is still in the background of the window and visable outside the square, then after&amp;nbsp;&lt;SPAN&gt;oWNview.WindowState = kMinimize for the only first time and before the folowing End If, the square appears as the only visable view, with the rest of the background grey, just to reset to its original size.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is happening only for the first time I go through the code or if I reset the view.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 06:20:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14222997#M181400</guid>
      <dc:creator>benedikt_seitzLXJD2</dc:creator>
      <dc:date>2026-08-05T06:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14224591#M181424</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/19360459"&gt;@benedikt_seitzLXJD2&lt;/a&gt;.&amp;nbsp; I finally found time to revisit this topic this morning.&amp;nbsp; If your main goal is to get a screen captured images of what is showing in Inventor's active View, and you need it to be square, instead of its natural rectangular shape, then there are likely other ways of achieving that which are less complicated.&amp;nbsp; Inventor's API has multiple methods for capturing images of what is showing within its views.&amp;nbsp; When we use those methods, we can specify the size of the image we want it to create, and the type of image file it will create.&amp;nbsp; Sometimes we can even dictate the 'background', or make it transparent, when it captures the image.&amp;nbsp; And if that were not enough, we could always just edit the resulting image after it is created too, if needed.&amp;nbsp; That can be done entirely by code, if needed.&amp;nbsp; The methods for creating images directly associated with an Inventor View are&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=View_SaveAsBitmap" target="_blank" rel="noopener"&gt;View.SaveAsBitmap&lt;/A&gt;,&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=View_SaveAsBitmapWithOptions" target="_blank" rel="noopener"&gt;View.SaveAsBitmapWithOptions&lt;/A&gt;, and&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=View_SaveAsBitmapWithRayTracing" target="_blank" rel="noopener"&gt;View.SaveAsBitmapWithRayTracing&lt;/A&gt;.&amp;nbsp;&amp;nbsp;Then there are similar methods of the Camera object that we can get from the &lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=GUID-View" target="_blank" rel="noopener"&gt;View&lt;/A&gt; through its&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=View_Camera" target="_blank" rel="noopener"&gt;View.Camera&lt;/A&gt;&amp;nbsp;property.&amp;nbsp;&amp;nbsp;The &lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=Camera_CreateImage" target="_blank" rel="noopener"&gt;Camera.CreateImage&lt;/A&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=Camera_CreateImageWithOptions" target="_blank" rel="noopener"&gt;Camera.CreateImageWithOptions&lt;/A&gt;&amp;nbsp;methods are both for creating IPictureDisp type images, for active internal digital use.&amp;nbsp; But the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=Camera_SaveAsBitmap" target="_blank" rel="noopener"&gt;Camera.SaveAsBitmap&lt;/A&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2027/ENU/?guid=Camera_SaveAsBitmapWithOptions" target="_blank" rel="noopener"&gt;Camera.SaveAsBitmapWithOptions&lt;/A&gt;&amp;nbsp;methods are similar to the View methods, but with a couple more options for dictating specific color backgrounds.&lt;/P&gt;
&lt;P&gt;Beyond that, there are a lot of code examples available online for editing or modifying existing images.&lt;/P&gt;
&lt;P&gt;I will post an example below, for starters, but it will be in vb.net, which can be used in an iLogic rule, not in VBA.&amp;nbsp; I stopped using VBA several years ago, around the same time Autodesk stopped including it in their standard installations for security purposes, because Microsoft stopped maintaining it.&amp;nbsp; The VB.NET coding system used in our iLogic rules has a lot of similarities, because it is still in the 'Visual Basic' language family, but is much newer, and offers more functionality and advantages.&amp;nbsp; If you are using an older version of Inventor where VBA macros were the only way to put a custom button into Inventor's ribbon, then I can understand that, but a VBA macro can simply call an iLogic rule to run, instead of containing all the code for the task in VBA.&amp;nbsp; The last several versions of Inventor have allowed us to put buttons in Inventor's ribbons that will run external iLogic rules or show global iLogic Forms, which was long anticipated in the Inventor automation world.&lt;/P&gt;
&lt;P&gt;I wrote the 'Main' block of code, and customized some of the other blocks of code a bit, but the core functionality of the image editing block of code I got from GPT 5.4 nano (an AI source).&amp;nbsp; I tested it locally on one of my Inventor models.&amp;nbsp; It saved a screen shot image of my model to a PNG file with a transparent background first, that was the full size of my View.&amp;nbsp; Then it opened that image file invisibly, and cropped it to a square, using the smaller dimension of either the original images width or its height, as the size for both sides of the square, then saved the result to a new file.&amp;nbsp; The second image was identical to the first image, and one of its dimensions is the same as the original, but with the longer dimension cropped towards the center of the image.&amp;nbsp; That sounds like what you were hoping to achieve, so I hope this will help you reach your goal.&amp;nbsp; And maybe help some others along the way too.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;AddReference "System.Drawing"
Imports System.Drawing
Imports System.Drawing.Imaging

Sub Main
	'hard-coded full file names...this can be changed later, if needed
	'could show an interactive file browser here instead
	Dim sOriginalImageFile As String = "C:\Temp\Inventor ScreenShot.png"
	Dim sCroppedImageFile As String = "C:\Temp\Inventor ScreenShot - Cropped To Square.png"
	'get Inventor's active View (assume the view is ready for screen capture)
	Dim oView As Inventor.View = ThisApplication.ActiveView
	'specify an Option for the image to have a transparent background
	'this only works for the PNG or TIFF Image types, not for GIF, BMP, or JPG
	Dim oOptions As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
	oOptions.Value("TransparentBackground") = True
	'using zero values (default) gets the entire view width &amp;amp; height
	oView.SaveAsBitmapWithOptions(sOriginalImageFile, 0, 0, oOptions)
	'allow Inventor to finish processing stuff in its queue
	ThisApplication.UserInterfaceManager.DoEvents()
	'call the custom Sub routine to Crop the image file from its original rectangular shape,
	'to a centered square, without squishing or deforming the image
	CropImageToCenteredSquare(sOriginalImageFile, sCroppedImageFile)
End Sub

Sub CropImageToCenteredSquare(imageFile As String, _
	Optional resultImageFile As String = Nothing)
	
	If String.IsNullOrWhiteSpace(resultImageFile) Then
		resultImageFile = imageFile
	End If

	Using oOrigImg As System.Drawing.Image = System.Drawing.Image.FromFile(imageFile)
		Dim dW As Integer = oOrigImg.Width
		Dim dH As Integer = oOrigImg.Height
		Dim dMinDim As Integer = Math.Min(oOrigImg.Width, oOrigImg.Height)
		Dim dX_Ctr As Integer = (dW - dMinDim) / 2
		Dim dY_Ctr As Integer = (dH - dMinDim) / 2
		Using bmp As New Bitmap(dMinDim, dMinDim, PixelFormat.Format24bppRgb)
			Using g As Graphics = Graphics.FromImage(bmp)
				g.CompositingMode = Drawing2D.CompositingMode.SourceCopy
				g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
				g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
				g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
				g.DrawImage(oOrigImg, New Rectangle(0, 0, dMinDim, dMinDim), _
				New Rectangle(dX_Ctr, dY_Ctr, dMinDim, dMinDim), GraphicsUnit.Pixel)
				'call other custom Sub routine to save this modified image to file
				SaveImageToFileByExtension(bmp, resultImageFile)
			End Using 'g Graphics
		End Using 'bmp
	End Using 'oOrigImg
End Sub

Sub SaveImageToFileByExtension(img As System.Drawing.Image, outPath As String)
	Dim sExt As String = System.IO.Path.GetExtension(outPath).ToLowerInvariant()
	Select Case ext
		Case ".png"
			img.Save(outPath, ImageFormat.Png)
		Case ".bmp"
			img.Save(outPath, ImageFormat.Bmp)
		Case ".gif"
			img.Save(outPath, ImageFormat.Gif)
		Case ".tif", ".tiff"
			img.Save(outPath, ImageFormat.Tiff)
		Case Else
			img.Save(outPath, ImageFormat.Jpeg)
	End Select
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;The image editing code could even take it a step further, if needed (with more complex code), to crop as much of a solid or transparent background away as possible, while still keeping the image square, and can even leave a margin of space around it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2026 13:16:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14224591#M181424</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2026-08-06T13:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14225834#M181437</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the Reply.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I like the idea of this so Thanks again, but it still lacks the possebility to adjust the objekts in the View so that they could be seen in the square before taking the picture. For this I would have to use the photo cutting code after my original code has adjusted the view then there is no need for the border of the View to be visable for the human eye.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Half of the problem is solved, but t&lt;/SPAN&gt;&lt;SPAN&gt;here is another problem for the first time of running the code: How do i prevent this jumping back to the original size I mentioned earlier.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It replaces the objeckts within the view back, outside the square.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2026 11:25:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14225834#M181437</guid>
      <dc:creator>benedikt_seitzLXJD2</dc:creator>
      <dc:date>2026-08-07T11:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14226028#M181440</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/19360459"&gt;@benedikt_seitzLXJD2&lt;/a&gt;.&amp;nbsp; I do see your point now, after a few tests.&amp;nbsp; If the model was long and slim, then it may not fit nicely in a square, so the 'Crop' process may actually be cutting off some of the model in the image.&amp;nbsp; So, the plan is to make the view square first, then 'fit' the model within that square view, then capture the image, then restore the view back to its original size &amp;amp; location when done.&amp;nbsp; I changed my code example to do just that.&amp;nbsp; My updated rule also 'manages' the View's parent ViewFrame, just in case that may be necessary.&amp;nbsp; And I added more code for helping with the full file name of the image file it is to create.&amp;nbsp; In doing so, just after I capture Inventor's active View at the start, I then capture the Document that is associated with that View.&amp;nbsp; If that Document has not been saved yet, it will not have a 'File' associated with it yet, so it will not have a path or file name yet.&amp;nbsp; I added a check just for that.&amp;nbsp; And I created 3 variables near the start, for capturing the path, and file name of that document, then using those to assemble the full file name of the image.&amp;nbsp; Using that assembled image full file name would save the new image in the same folder, and with the same name as the document's File, but with the '.png' file extension.&amp;nbsp; However, I also added a custom standalone Function just for allowing a FileDialog prompt to the user, so they can manually browse to the folder, type in a file name and file extension.&amp;nbsp; But the way I designed it below, that method will only be used if you did not change the 'Default' (empty) values of those variables, and the document has not been saved yet.&amp;nbsp; When those two things are true, the String variable for the image's full file name will still be empty, which causes that prompt to show.&amp;nbsp; But you can change that however you want.&amp;nbsp; Just including all the 'tools' for the task, to make it easier later.&amp;nbsp; The updated iLogic rule code example is below.&amp;nbsp; I added lots of 'comments' in there, to explain what each block of code is for.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Sub Main
	'get Inventor's active View
	Dim oView As Inventor.View = ThisApplication.ActiveView
	'get the View's Document
	Dim oDoc As Inventor.Document = oView.Document
	If oDoc Is Nothing Then Exit Sub
	
	Dim sPath As String = Nothing 'or a Default value
	Dim sFileName As String = Nothing 'or a Default value
	Dim sImageFile As String = Nothing 'or a Default value
	
	'if the Document has never been saved, it will not have a File (no path or file name)
	If Not oDoc.FileSaveCounter = 0 Then
		Dim sFFN As String = oDoc.FullFileName
		'gets the full file path, without file name
		sPath = System.IO.Path.GetDirectoryName(sFFN)
		'gets just the file name, without file extension (no file path)
		sFileName = System.IO.Path.GetFileNameWithoutExtension(sFFN)
		'combine path &amp;amp; file name, by adding your system's directory separator character
		sImageFile = System.IO.Path.Combine(sPath, sFileName &amp;amp; ".png")
	End If
		
	'&amp;lt;&amp;lt;&amp;lt; VIEW FRAME &amp;gt;&amp;gt;&amp;gt;
	'get the View's Parent ViewFrame
	Dim oVF As Inventor.ViewFrame = oView.ViewFrame
	'record its size, location, &amp;amp; state, so we can restore it later
	Dim oOrigVFBounds As List(Of Integer)
	Dim eOrigVFState As Inventor.WindowsSizeEnum
	Dim bVF_Max As Boolean = (oVF.WindowState = Inventor.WindowsSizeEnum.kMaximize)
	If Not bVF_Max Then
		oOrigVFBounds = New List(Of Integer) From {oVF.Top, oVF.Left, oVF.Height, oVF.Width}
		eOrigVFState = oVF.WindowState
		oVF.WindowState = Inventor.WindowsSizeEnum.kMaximize
	End If
	
	'&amp;lt;&amp;lt;&amp;lt; VIEW &amp;gt;&amp;gt;&amp;gt;
	'maximize View, then make it square, then Zoom All, Save Image
	'record View size, location, &amp;amp; state, so we can restore it later
	Dim iTop, iLeft, iHeight, iWidth As Integer
	oView.GetWindowExtents(iTop, iLeft, iHeight, iWidth)
	Dim oOrigVBounds As List(Of Integer) = New List(Of Integer) From {iTop, iLeft, iHeight, iWidth }
	Dim eOrigViewState As Inventor.WindowsSizeEnum = oView.WindowState
	If Not oView.WindowState = Inventor.WindowsSizeEnum.kMaximize Then
		oView.WindowState = Inventor.WindowsSizeEnum.kMaximize
	End If
	
	'now make the View square by shrinking its largest size to match its other size
	'no need to move the view's top left corner
	If iHeight &amp;gt; iWidth Then
		iHeight = iWidth
	ElseIf iHeight &amp;lt; iWidth Then
		iWidth = iHeight
	End If
	oView.Height = iHeight
	oView.Width = iWidth
		
	'now 'Fit' the model within this square View or Zoom All
	oView.Fit(True)
	
	'if no 'Default' Image full file name was specified, and the Document has not been saved,
	'then prompt the user with a FileDialog, so they can manually specify the full file name
	If String.IsNullOrWhiteSpace(sImageFile) Then
		sImageFile = UseFileDialog(True, "Specify Full Path, Name, &amp;amp; Image File Type")
	End If
	
	'now capture the Image
	'specify an Option for the image to have a transparent background
	'this only works for the PNG or TIFF Image types, not for GIF, BMP, or JPG
	Dim oOptions As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
	oOptions.Value("TransparentBackground") = True
	'using zero values (default) gets the entire view width &amp;amp; height
	oView.SaveAsBitmapWithOptions(sImageFile, 0, 0, oOptions)
	'allow Inventor to finish processing stuff in its queue
	ThisApplication.UserInterfaceManager.DoEvents()
	
	'now restore ViewFrame and View back to their original state, location, &amp;amp; size
	If Not bVF_Max Then
		oVF.WindowState = eOrigVFState
		oVF.Move(oOrigVFBounds.Item(0), oOrigVFBounds.Item(1), oOrigVFBounds.Item(2), oOrigVFBounds.Item(3))
	End If
	oView.WindowState = eOrigViewState
	oView.Move(oOrigVBounds.Item(0), oOrigVBounds.Item(1), oOrigVBounds.Item(2), oOrigVBounds.Item(3))
	oView.Fit(True)
End Sub

Function UseFileDialog(Optional save As Boolean = False, Optional title As String = Nothing) As String
	Dim oFDlg As Inventor.FileDialog
	ThisApplication.CreateFileDialog(oFDlg)
	oFDlg.DialogTitle = IIf(String.IsNullOrWhiteSpace(title), "Specify Full File Name", title)
	oFDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
	'oFDlg.Filter = "Autodesk Inventor Files (*.iam;*.dwg;*.idw;*.ipt) | *.iam;*.dwg;*.idw;*ipt | All files (*.*)|*.*"
	oFDlg.Filter = "All files (*.*)|*.*"
	oFDlg.MultiSelectEnabled = False
	oFDlg.OptionsEnabled = False
	oFDlg.InsertMode = False
	oFDlg.CancelError = True
	Try
		If save = True Then
			oFDlg.ShowSave()
		Else
			oFDlg.ShowOpen()
		End If
	Catch
	End Try
	Return oFDlg.FileName
End Function&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2026 13:56:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14226028#M181440</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2026-08-07T13:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14227927#M181449</link>
      <description>&lt;P&gt;Thank you verry much for helping me out of this problem.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2026 06:29:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14227927#M181449</guid>
      <dc:creator>benedikt_seitzLXJD2</dc:creator>
      <dc:date>2026-08-10T06:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get a Grey Background with adjusted View-size, when more than one Document is open.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14227937#M181451</link>
      <description>&lt;P&gt;Wonderfuul!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2026 06:38:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-a-grey-background-with-adjusted-view-size-when-more-than-one/m-p/14227937#M181451</guid>
      <dc:creator>iva.btblan</dc:creator>
      <dc:date>2026-08-10T06:38:54Z</dc:date>
    </item>
  </channel>
</rss>

