Add bones to a figure via script

Is there a way to add bones to an existing figure via script? Preferably sibling bones under the root figure (not the root hip/pelvis).

I intend to use these bones for parenting props to for use in Puppeteer allowing for in sync animation (as Puppeteer can only work on a single figure for a single graph). This helps streamline my workflow and give significant time savings.

Even better if I am able to merge figures - if this is possible. Although the pie in the sky would be if DAZ can allow Puppeteer to work with any props/figures in the entire Scene.

Comments

  • OmnifluxOmniflux Posts: 359

    I have not done this, but as the scripting documentation is lacking in this area I would look at this SDK example. The SDK and and script API are very similar and you should be able to adapt it.

    https://www.daz3d.com/forums/discussion/58162/dzbone-and-weight-maps-handling-in-the-sdk

  • cain-xcain-x Posts: 155

    This is some really good info - I will try this and see if I can manage something. Thanks.

  • cain-xcain-x Posts: 155

    The references above helped! This is the working code I have (tested in 4.20 and 4.21):

    beginUndo();var tgtFigure = Scene.getSelectedNode(0);var parts = ["Brake", "Gas", "Steer", "Clutch", "Key", "Shift"];if(!tgtFigure){	print("You must select a Figure.");}else{	print(tgtFigure.getLabel());			for(var i = 0; i < parts.length; i++ )	{		var partNode = Scene.findNodeByLabel(parts[i]);				if(partNode)		{			if(!partNode.getSkeleton())			{				// make a bone				var tgtBone = new DzBone();				tgtBone.setRotationOrder( tgtFigure.getRotationOrder() );				tgtBone.setOrigin( DzVec3(0, 0, 0), true );				tgtBone.setEndPoint( DzVec3(0, 0, 1), true );				tgtBone.setOrientation( DzQuat(), true );				tgtBone.setName(parts[i]);				tgtBone.setLabel(parts[i]);				tgtBone.setInheritScale( true );								// add the bone				Scene.addNode( tgtBone );				tgtFigure.addNodeChild( tgtBone );								// position bone to prop in WS				tgtBone.setWSPos(partNode.getWSPos());				tgtBone.setWSRot(partNode.getWSRot());								// parent part to bone (must be unparented)				var parent = partNode.getNodeParent();				if(parent)				{					parent.removeNodeChild(partNode, true);				}				tgtBone.addNodeChild(partNode, true);			}			else			{				tgtFigure.addNodeChild(partNode, true);			}					}		else		{			print("Part " + parts[i] + " was not found in the Scene!");		}	}}acceptUndo("Add control bones");

     

Sign In or Register to comment.