Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Viewer Background Color results in error 1

Status
Not open for further replies.

CheeseMaker13

Aerospace
Sep 25, 2012
42
GB
Hi Guys,

I have the following code:

Code:
Dim objViewer3D As Viewer3D
Dim objCamera3D As Camera3D

Set MainDocument = CATIA.ActiveDocument
Set objCamera3D = MainDocument.Cameras.Item(1)
    
objViewer3D.Viewpoint3D = objCamera3D.Viewpoint3D

Dim DBLBackArray(2)
objViewer3D.GetBackgroundColor DBLBackArray
Dim dblWhiteArray(2)
dblWhiteArray(0) = 1
dblWhiteArray(1) = 1
dblWhiteArray(2) = 1
objViewer3D.PutBackgroundColor dblWhiteArray

Comes up with error: "Compile Error: Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic" on the "GetBackgroundColor" and "PutBackgroundColor" code.

I'm not doing this via catscript, but the normal Visual Basic window.

Anyone got any ideas or another solution?

Version V5R18.

Cheers!
 
Replies continue below

Recommended for you

Hi

I suppose you are trying to get a screenshot....should work...

Code:
Dim MyViewer As Viewer
Set MyViewer = CATIA.ActiveWindow.ActiveViewer

'-----get Active Background 
Dim color(2)
Dim MyViewer2
Set MyViewer2 = MyViewer
MyViewer2.GetBackgroundColor color

'-----set white background
MyViewer2.PutBackgroundColor Array(1, 1, 1)

'code to capture screen in what image format you want and path

'-----back to original backgroung
MyViewer2.PutBackgroundColor (color)


Regards
Fernando

 
Thks Fernando, I looked at it a while ago and could make it work... How many times do we have to trick CATIA to make it work??

For those who did not notice:

Code:
[COLOR=#CC0000]Dim MyViewer As Viewer[/color]
Set MyViewer = CATIA.ActiveWindow.ActiveViewer

'-----get Active Background 
Dim color(2)
[highlight #CC0000]Dim MyViewer2[/highlight]
[highlight #CC0000]Set MyViewer2[/highlight] = [COLOR=#CC0000]MyViewer[/color]
[highlight #CC0000]MyViewer2[/highlight].GetBackgroundColor color


[thumbsup2] star for you

Nice

Eric N.
indocti discant et ament meminisse periti
 
HI
I tried ferdo's code but still my background colour stays in white. Doesnt get back to old color after putbackground colour statement. Am i missing something

Any suggestions
Thanks
Barath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top