Is this by design?
In 2014 when saving an image using the Camera.SaveAsBitMap method the saved image aspect ratio seems distorted by width / height.
If the width and height are set to the same value the ratio is correct.
I tried the following code for the same view in the Inventor 2014 UI:
Private Sub SizeTest() Dim V As View Set V = ThisApplication.ActiveView Dim cam As Camera Set cam = V.Camera Call cam.SaveAsBitmap("C:\Temp\Test_100x200.png", 100, 200) Call cam.SaveAsBitmap("C:\Temp\Test_200x100.png", 200, 100) Call cam.SaveAsBitmap("C:\Temp\Test_200x200.png", 200, 200) Call cam.SaveAsBitmap("C:\Temp\Test_ViewSize.png", V.Width, V.Height) Beep End Sub
Here are my results:
Thanks for the reponse. I tried your code and it worked the same for me as it did for you. Then I modified it to mimic the way I am using the command. The difference is I create a camera manually, set the view and save with a different background color.
Here's my code.
Sub Main Dim V As View V = ThisApplication.ActiveView Dim cam As Camera cam = ThisApplication.TransientObjects.CreateCamera() cam.SceneObject = ThisDoc.Document.ComponentDefinition cam.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation cam.ApplyWithoutTransition() Dim bkColor As Color bkColor = ThisApplication.TransientObjects.CreateColor(255, 255, 255, 0) cam.SaveAsBitmap("C:\Temp\RTest_100x200.png", 100, 200, bkColor, bkColor) cam.SaveAsBitmap("C:\Temp\RTest_200x100.png", 200, 100, bkColor, bkColor) cam.SaveAsBitmap("C:\Temp\RTest_200x200.png", 200, 200, bkColor, bkColor) cam.SaveAsBitmap("C:\Temp\RTest_ViewSize.png", V.Width, V.Height, bkColor, bkColor) End Sub
And here are my results.
If the background color is not changed it still produces the same results. Is the camera created through TransientObjects and the ActiveView camera different types of camera objects?
Thanks
It looks like you found a problem in the API. I can reproduce this effect with TransientCamera. It looks like TransientCamera.SaveAsBitmap method works correctly only if Width = Height. I noticed also that the result could be additionally distorted if you call Camera.Fit method.
I logged appropriate change request.
Thank you a lot!
Cheers