Custom UI : what is the html code for the Scene Browser "Styles" tab ?

 From:  Michael Gibson
10119.4 In reply to 10119.3 
Hi Pior,

re:
> On that topic, are there any shortcuts/commands related to the Styles tab ?

Yes there are several ways that scripts can access and modify style data.


> Like for instance to put the current selected objects inside a given color layer,

That would go like this:

script: var style = moi.geometryDatabase.findStyle( 'Green', true /*CreateIfNotFound*/ ); moi.geometryDatabase.getSelectedObjects().setProperty( 'styleIndex', style.index );


> and hiding/unhiding a Style altogether.

That's done by hiding/unhiding objects that have a given style index, like this:

script: /* Hide objects with style = Green */ var style = moi.geometryDatabase.findStyle( 'Green', true /*CreateIfNotFound*/ ); var objs = moi.geometryDatabase.getObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); if ( obj.styleIndex == style.index ) { obj.hidden = true; } }

script: /* Show objects with style = Green */ var style = moi.geometryDatabase.findStyle( 'Green', true /*CreateIfNotFound*/ ); var objs = moi.geometryDatabase.getObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); if ( obj.styleIndex == style.index ) { obj.hidden = false; } }

- Michael