Export to tiff without background

Export to tiff without background

CAD_CAM_MAN
Advocate Advocate
473 Views
2 Replies
Message 1 of 3

Export to tiff without background

CAD_CAM_MAN
Advocate
Advocate

Using Inventor Pro 2022 Build 350...

 

I have created a rule that among other things exports a .tiff image of the currently active drawing to a specified directory. I use ActiveView.Fit before exporting the .tiff file. The problem is "the background" of the window shows if the actual window size is not adjusted to outline the sheet exactly. I can get the desired result by pulling the tree browser window over to get the sheet to fit the window more precisely but would like to automate this regardless of how the users window is currently adjusted.

 

The sheet size will always be 11 X 17

 

Is there a way to just export the sheet to a .tiff without the background?

If no, is there a way to adjust the tree browser window via the API?

 

 

 

Desired result (tree browser adjusted)...

CAD_CAM_MAN_3-1659991002462.png

Resulting .tiff...

CAD_CAM_MAN_0-1659990202296.png

 

Undesired (background shows)...

CAD_CAM_MAN_2-1659990825022.png

Resulting .tiff...

CAD_CAM_MAN_1-1659990422892.png

 

 

 

0 Likes
Accepted solutions (1)
474 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

I found the following rule in this very old post. Just cleaned and converted it to an iLogic rule.

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As View = ThisApplication.ActiveView

Dim dAspectRatio As Double = oSheet.Height / oSheet.Width

' Adjust the aspect ratio of the view to match that of the sheet
oView.Height = oView.Width * dAspectRatio

Dim oCamera As Camera = oView.Camera
' Center the sheet to the view
oCamera.Fit()
' Zoom to fit the sheet exactly within the view
' Add some tolerance to make sure the sheet borders are contained
oCamera.SetExtents(oSheet.Width * 1.003, oSheet.Height * 1.003)

' Apply changes to the camera
oCamera.Apply()

' Save view to jpg. Make sure that the aspect ratio is maintained when exporting
Call oView.SaveAsBitmap("D:\forum\2022\bakje.tiff", 800, 800 * dAspectRatio)

' Restore the view
oCamera.Fit()
oCamera.Apply()
oView.WindowState = WindowsSizeEnum.kMaximize

 

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.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

CAD_CAM_MAN
Advocate
Advocate

Perfect! Just what I was looking for.

Thank you JelteDeJong!

0 Likes