mcjReplaceTheseByThis - bake them un-exportable instances - and more

mCasualmCasual Posts: 4,604
edited September 2019 in Freebies

New script ! replace those non-exportable instances with real things - or replace many things by one thing

https://sites.google.com/site/mcasualsdazscripts9/mcjreplacethesebythis


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

Introduction

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

Initially i just wanted a script to replace instances of Guitar Stacks by real Guitar stacks

because the instances are not exported when you export a scene as fbx or obj etc ...

but this script can replace anythings with anything

itsbacon.jpg
800 x 600 - 218K
Post edited by mCasual on

Comments

  • mCasualmCasual Posts: 4,604

    since the script is quite simple here's the core functions

     

    var actionMgr = MainWindow.getActionMgr();...function doit(){	var selectedNodes = Scene.getSelectedNodeList()	var n = selectedNodes.length;	if( n < 2 )	{		var msg = 		"Problem: You must select\n" +			"1 - The source thing: a prop or primitive or figure\n" +			"2 - One or many destination things ( could be instances of something )"		MessageBox.information( msg, "Can't do it", "OK" );		return;	}	mainNode = selectedNodes[0]	for( var i = 1; i < n; i++ )	{		node = selectedNodes[i];		replace( node, mainNode )	}}function replace( node, srcNode ){	Scene.selectAllNodes( false );	node.select( true );	doAction( "DzCopyNodeAction" );	node.select( false );	var nodez = Scene.getNodeList();	var nn = nodez.length			srcNode.select( true );	doAction( "DzDuplicateNodeHierarchyAction" );	srcNode.select( false );	nodez = Scene.getNodeList();	nunode = nodez[nn]	nunode.select( true );	doAction( "DzPasteNodeAction" );	nunode.select( false );	var ctl = nunode.getScaleControl();	if( ctl.getValue() == 0 ) ctl.setValue( 1 );	var ctl = nunode.getXScaleControl();	if( ctl.getValue() == 0 ) ctl.setValue( 1 );	var ctl = nunode.getYScaleControl();	if( ctl.getValue() == 0 ) ctl.setValue( 1 );	var ctl = nunode.getZScaleControl();	if( ctl.getValue() == 0 ) ctl.setValue( 1 );		Scene.removeNode( node );}function doAction( nm ){	action = actionMgr.findAction( nm );	action.trigger()}

     

  • Nice, instances are very usefull. Thank you

  • Very very useful Teleblender companion. Thank you so much.

  • Thanks very much for this script. I clicked on the "Donate Button" and it didn't work.

  • Althoughhhhh....(Not to split hairs about a free helper, but...(I think people should know))...

    In DAZ 4.21.05, it's acting more like an "exploder" of instances, unfortunately, and there's no way to undo the effect. In the end, it didn't work out for me.

  • mCasualmCasual Posts: 4,604
    edited December 2023

    i don't remember exactly but you probably needed to keep instances grouped or parented at root level and not change the label/name of what created the instances but i'm not sure what you mean about exploding, i guess the script hmmm maybe  back then i didn't use the built-in daz studio duplicator, this would be a very quick and safe way to do it. So by exploding you probably mean that the real object each with all its goodies doesn't get placed at the same location as the instance it is replacing. and the solution would possibly be to freeze the scene and unparent the instances so that they are at root level where world space is the same as local space and the script's life is made easy. the thing about freezing the scene is that it seems to facilitate un-parenting things without them jumping to wherever. i have a script to do that updated not too many years ago hopefully https://www.daz3d.com/forums/discussion/58850/mcjfreezethings-script-for-ds1-2-3-4-freeze-non-figures-for-animators there's another one or this one where you can specify what gets frozen

     

    RyanDurney_0907c70bf7 said:

    Althoughhhhh....(Not to split hairs about a free helper, but...(I think people should know))...

    In DAZ 4.21.05, it's acting more like an "exploder" of instances, unfortunately, and there's no way to undo the effect. In the end, it didn't work out for me.

    Post edited by mCasual on
Sign In or Register to comment.