mcjMakeAutoFollowSwitcher

================================================================================

Introduction

================================================================================

This script will create a script that will reinstate the "autoFollow" property of each property

and of each morph for the selected figure

================================================================================

History

================================================================================

April23rdth 2017 5:37 PM - Released

================================================================================

Installation

================================================================================

The script is found at the bottom of this page

================================================================================

Use

================================================================================

Set the AutoFollow option of the properties and morphs to your liking

Select the figure

Run the script

Specify the filename and location for the output script ( warning : the script doesnt prevent you from overwriting the file with the same location and same name )

later on

select the figure

run the script produced in the previous step

================================================================================

Code

================================================================================

// DAZ Studio version 4.9.3.166 filetype DAZ Script // copyrights mCasualJacques : public domain // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. var appName = "mcjMakeAutoFollowSwitcher" var def_outFile = App.getTempPath() + "/" + "AutoFollowSwitcher" + ".dsa"; var node = Scene.getPrimarySelection(); if( node ) { if( node.inherits( "DzBone" ) ) { node = node.getSkeleton(); } var filename = Browse(); if( filename ) { var file = new DzFile( filename ); file.open( file.WriteOnly ); file.writeLine( "var todoList = [" ); var n = node.getNumProperties() for( var i = 0; i < n; i++ ) { var prop = node.getProperty( i ); if( i > 0 ) { file.write( ", " ); } else { file.write( " " ); } file.writeLine( "[ \"" + prop.name + "\", " + prop.canAutoFollow() + " ]" ) } file.writeLine( "];" ); file.writeLine( "var morphList = [" ); var obj = node.getObject(); var n = obj.getNumModifiers(); var bOneDone = false; for( var i = 0; i < n; i++ ) { var mod = obj.getModifier( i ); if( mod.inherits( "DzMorph" ) ) { if( bOneDone ) { file.write( ", " ); } else { file.write( " " ); } var prop = mod.getValueChannel(); file.writeLine( "[ \"" + mod.name + "\", " + prop.canAutoFollow() + " ]" ) bOneDone = true; } } file.writeLine( "];" ); file.writeLine( "var node = Scene.getPrimarySelection();" ); file.writeLine( "if( node )" ); file.writeLine( "{" ); file.writeLine( " if( node.inherits( 'DzBone' ) )" ); file.writeLine( " {" ); file.writeLine( " node = node.getSkeleton();" ); file.writeLine( " }" ); file.writeLine( " var n = todoList.length;" ); file.writeLine( " for( var i = 0; i < n; i++ )" ); file.writeLine( " {" ); file.writeLine( " var item = todoList[i];" ); file.writeLine( " var prop = node.findProperty( item[0] )" ); file.writeLine( " if( prop )" ); file.writeLine( " {" ); file.writeLine( " prop.setCanAutoFollow( item[1] );" ); file.writeLine( " }" ); file.writeLine( " }" ); file.writeLine( "}" ); file.writeLine( "var n = morphList.length;" ); file.writeLine( "var obj = node.getObject();" ); file.writeLine( "for( var i = 0; i < n; i++ )" ); file.writeLine( "{" ); file.writeLine( " var item = morphList[i];" ); file.writeLine( " var mod = obj.findModifier( item[0] );" ); file.writeLine( " if( mod )" ); file.writeLine( " {" ); file.writeLine( " var prop = mod.getValueChannel();" ); file.writeLine( " prop.setCanAutoFollow( item[1] );" ); file.writeLine( " }" ); file.writeLine( "}" ); file.close(); } } //======================================================================= // //======================================================================= function Browse() { var filename = FileDialog.doFileDialog( false, "Specify the AutoFollow Switcher script that will be produced", getSetting( "outputFilename", def_outFile ), "Daz Script (*.dsa);" ); if( filename ) { saveSetting( "outputFilename", filename ) } return( filename ); } //============================================================================== // save key/val in Registry for Windows, // via the Carbon Preferences API for Mac //============================================================================== function saveSetting( key, keyVal ) { var m_oMgr = App.getAppSettingsMgr(); m_oMgr.pushPath( appName ); m_oMgr.setStringValue( key, keyVal ); m_oMgr.popPath(); } //============================================================================== // load key/val from Registry for Windows, // via the Carbon Preferences API for Mac //============================================================================== function getSetting( key, defVal ) { var m_oMgr = App.getAppSettingsMgr(); m_oMgr.pushPath( appName ); var val = m_oMgr.getStringValue( key, defVal ); m_oMgr.popPath(); return ( val ); }

License

// =====================================================================

// by mCasual/Jacques

// public domain

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,

// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES

// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND

// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT

// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,

// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR

// OTHER DEALINGS IN THE SOFTWARE.

// =====================================================================