cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to change transparency of objects through script

cmodin
8-Gravel

How to change transparency of objects through script

Basically the title, I've been trying use the opacity value to make a model part "fade" away but when I change the value, it's reflected when I print it to console but not on the model itself. Thanks!

ACCEPTED SOLUTION

Accepted Solutions

You will need to write a loop to change the opacity in increments over time to get your fade. But there are two ways to actually change opacity value:

$scope.setWidgetProp('myObjectName', 'opacity', 0.5); //opacity values are 0-1
$scope.view.wdg['myObjectName'].opacity = 0.5;

Generally the setWidgetProp method is the most reliable at triggering a view refresh and actually showing the change you made. But you may get different results with 2D and 3D widgets.

 

I would share some code snippets of what you have so far if you want more detailed feedback.

View solution in original post

2 REPLIES 2

You will need to write a loop to change the opacity in increments over time to get your fade. But there are two ways to actually change opacity value:

$scope.setWidgetProp('myObjectName', 'opacity', 0.5); //opacity values are 0-1
$scope.view.wdg['myObjectName'].opacity = 0.5;

Generally the setWidgetProp method is the most reliable at triggering a view refresh and actually showing the change you made. But you may get different results with 2D and 3D widgets.

 

I would share some code snippets of what you have so far if you want more detailed feedback.

I've been using a loop with: $scope.view.wdg[lbl]['opacity'] -= 0.005;

 

I'll try your two suggestions and see if that fixes it

Announcements

Top Tags