Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Apprentice Viewer Background Colour

ianjwellings
Contributor

Apprentice Viewer Background Colour

ianjwellings
Contributor
Contributor

I'm currently using the Apprentice Viewer to view Inventor files in my C# application. Is there any way to change the viewer background colour from blue to white?

0 Likes
Reply
402 Views
3 Replies
Replies (3)

JelteDeJong
Mentor
Mentor

You did not specify how you get the images, but i guess you use the camera class. Brian Ekins wrote a greate post about using the camera. you can find it here. In that post you will find the following code. in the last lines he shows how to set the background color when the picture is saved.

Private Sub CreateImage( _
              Apprentice As Inventor.ApprenticeServerComponent, _
              PartOrAssembly As Inventor.ApprenticeServerDocument, _
              Filename As String)
   ' Create a new camera.
   Dim cam As Inventor.Camera
   cam = Apprentice.TransientObjects.CreateCamera

   ' Associate the document with the camera.
   cam.SceneObject = PartOrAssembly.ComponentDefinition

   ' Define the camera and apply the changes.
   cam.ViewOrientationType = _
        Inventor.ViewOrientationTypeEnum.kIsoTopRightViewOrientation
   cam.Fit()
   cam.ApplyWithoutTransition()

   ' Save the result, defining the background color of the image.
   cam.SaveAsBitmap(Filename, 800, 600, _
           Apprentice.TransientObjects.CreateColor(255, 255, 0), _ 
           Apprentice.TransientObjects.CreateColor(15, 15, 15))
End Sub

 

 

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

0 Likes

ianjwellings
Contributor
Contributor

Thank you for the quick response.

I'd like to change the background colour in the picturebox ClientView if possible? Without having to export as an image.

This is the code I'm using:

 

oSvr = new Inventor.ApprenticeServerComponent();
oAppDoc = oSvr.OpenWithOptions(strFullDocumentName, oDocOpenOptions);
oClientView = oAppDoc.ClientViews.Add(pictureBox1.Handle.ToInt32());

oCamera = oClientView.Camera;
oCamera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation;
oCamera.Perspective = true;
oCamera.Apply();
this.Refresh();
oClientView.Update(false);

 

 

0 Likes

ianjwellings
Contributor
Contributor

Thank you for the quick response.

I'd like to change the background colour in the picturebox ClientView if possible? Without having to export as an image.

This is the code I'm using:

oSvr = new Inventor.ApprenticeServerComponent();
oAppDoc = oSvr.OpenWithOptions(strFullDocumentName, oDocOpenOptions);
oClientView = oAppDoc.ClientViews.Add(pictureBox1.Handle.ToInt32());

oCamera = oClientView.Camera;
oCamera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation;
oCamera.Perspective = true;
oCamera.Apply();
this.Refresh();
oClientView.Update(false);
0 Likes