×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Setting Viewer Background Color results in error

Setting Viewer Background Color results in error

Setting Viewer Background Color results in error

(OP)
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!

RE: Setting Viewer Background Color results in error

Hi

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

CODE --> vba

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Setting Viewer Background Color results in error

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 --> vba

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

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


thumbsup2 star for you

Nice

Eric N.
indocti discant et ament meminisse periti

RE: Setting Viewer Background Color results in error

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources