User Tools

Site Tools


Toggle Universal View Tool Snapping

Summary

Below is an example demonstrating how you can toggle snapping of the universal view tools, via script.

API Areas of Interest

Example

View_Tool_Toggle_Snapping.dsa
// DAZ Studio version 4.11.0.53 filetype DAZ Script
 
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
 
	// Get the viewport manager
	var oViewportMgr = MainWindow.getViewportMgr();
	// If we do not have a viewport manager
	if( !oViewportMgr ){
		// We are done...
		return;
	}
 
	// Get the active view tool
	var oTool = oViewportMgr.getActiveTool();
	// If the tool does not inherit the class we want;
	// e.g., DzUniversalTool, DzUniversalRotateTool,
	// DzUniversalTranslateTool, DzUniversalScaleTool
	if( !oTool.inherits( "DzUniversalTool" ) ){
		// We are done...
		return;
	}
 
	// Toggle the snapping tool setting
	oTool.setSnapTranslation( !oTool.getSnapTranslation() );
	//oTool.setSnapRotation( !oTool.getSnapRotation() );
	//oTool.setSnapScale( !oTool.getSnapScale() );
 
// Finalize the function and invoke
})();