Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# API Inventor 2012 Change Image Background to white

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1119 Views, 2 Replies

C# API Inventor 2012 Change Image Background to white

i want to change the backgroun color to a solid white before i save an image of an .iam to file.

so far:

 

Inventor.Color bgColor = InvApp.TransientObjects.CreateColor(255, 255, 255);

Camera.SaveAsBitmap("C:\\Users\\Dan\\Desktop\\test.jpg", 800, 800, bgColor);

 

This does nothing to the image, same gradient BG set from the colorschemes.

 

i tried:

 

InvApp.ColorSchemes.BackgroundType = BackgroundTypeEnum.kOneColorBackgroundType;

 

just for giggles and it does in fact change the BG to a solid grey. But after that, i see no way to change the BG.

 

 

InvApp.ColorSchemes.Item("Presentation").Activate;

 

does not work either as the .Item sub class does not even under the colorschemes object.

 

im sure i am passing the wrong color object to the saveasbitmap method anyway - i just need someone to tell me the right object.....but this forum is a desert for anything not 2013....

 

cheers

 

2 REPLIES 2
Message 2 of 3
augusto.goncalves
in reply to: Anonymous

Sounds like correct, here's a sample for your reference, note that it's passing 2 colors

 

Sub test()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oView As View
Set oView = oDoc.Views(1)

'Get the camera from the active view
Set oCamera = oView.Camera
oCamera.Fit
oCamera.Apply

Dim oTO As TransientObjects
Set oTO = ThisApplication.TransientObjects
Dim oTop As Color
Set oTop = oTO.CreateColor(255, 0, 0)

Dim oBottom As Color
Set oBottom = oTO.CreateColor(255, 255, 255)

oCamera.SaveAsBitmap "C:\ViewCamera.jpg", 800, 600, oTop, oBottom

End Sub

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 3
carol3QK4E
in reply to: Anonymous

Just use this code and it will work fine for your needs.

Sub test()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

Dim oView As View
Set oView = oDoc.Views(1)

'Get the camera from the active view
Set oCamera = oView.Camera
oCamera.Fit
oCamera.Apply

Dim oTO As TransientObjects
Set oTO = ThisApplication.TransientObjects
Dim oTop As Color
Set oTop = oTO.CreateColor(255, 0, 0)

Dim oBottom As Color
Set oBottom = oTO.CreateColor(255, 255, 255)

oCamera.SaveAsBitmap "C:\ViewCamera.jpg", 800, 600, oTop, oBottom

End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report