User Tools

Site Tools


Active Viewport DrawStyle

Summary

Below is an example demonstrating how you can set the DrawStyle on the active Viewport, via script.

API Areas of Interest

Example (Get)

Active_Viewport_Get_DrawStyle.dsa
// DAZ Studio version 4.9.2.23
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	// Get the viewport manager
	var oViewportMgr = MainWindow.getViewportMgr();
 
	// Get the active viewport
	var oViewport = oViewportMgr.getActiveViewport();
 
	// Get the 3D viewport
	var o3dViewport = oViewport.get3DViewport();
 
	// Set the DrawStyle
	print( o3dViewport.getUserDrawStyle() );
 
// Finalize the function and invoke
})();

Example (Set)

Active_Viewport_Set_DrawStyle.dsa
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function( sDrawStyle ){
 
	// Get the viewport manager
	var oViewportMgr = MainWindow.getViewportMgr();
 
	// Declare a working variable
	var oDrawStyle;
 
	// If a DrawStyle was not specified
	if( sDrawStyle.isEmpty() ){
		// Get the number of DrawStyles
		var nDrawStyles = oViewportMgr.getNumUserDrawStyles();
		// Iterate over the DrawStyles
		for( var i = 0; i < nDrawStyles; i += 1 ){
			// Get the 'current' DrawStyle
			oDrawStyle = oViewportMgr.getUserDrawStyle( i );
 
			// Inform the user
			print( oDrawStyle.getDescription() );
		}
 
		// We are done...
		return;
	}
 
	// Find a DrawStyle by label
	var oDrawStyle = oViewportMgr.findUserDrawStyle( sDrawStyle );
	// If we do not have a DrawStyle with that label
	if( !oDrawStyle ){
		// Inform the user
		print( sDrawStyle, "could not be found." );
 
		// We are done...
		return;
	}
 
	// Get the active viewport
	var oViewport = oViewportMgr.getActiveViewport();
 
	// Get the 3D viewport
	var o3dViewport = oViewport.get3DViewport();
 
	// Set the DrawStyle
	o3dViewport.setDrawStyle( oDrawStyle );
 
// Finalize the function and invoke
})( "Texture Shaded" );