Controlling A Morph Slider From A Parameter Slider - what object type is it ?

3dcheapskate3dcheapskate Posts: 2,719

Answer Part 1: A morph is a DzModifier on a DzShape on a DzObject on a DzNode, and not a DzProperty on a DzNode. Simple ! See this post below.

Answer Part 2: That's not quite true - a morph is actually a DzMorph, which is an undocumented derivative of DzModifier. See Richards comments below, here and here. The morph name is the name property of the DzMorph itself. However, the numeric value for the morph (which is what you see/control with the morph slider) is a DzProperty (having the name "Value") on the DzMorph.  To get/set the numeric value of the morph you call the getValue()/setValue() method of the DzProperty called "Value".
Can you see why I refer to all of this as Object Obfuscation ? wink

Answer Part 3: So to control a morph from an ordinary parameter it appears that you set up an ERC link in the usual way using the insertController() method of the DzProperty named "Value" on the DzMorph. I think

~ ~ ~ ~ ~ ORIGINAL OP STARTS HERE ~ ~ ~ ~ ~

I have a simple prop with a single node.

Creating a DzERCLink between two sliders on the Parameters tab is not (usually) a problem ( https://www.daz3d.com/forums/discussion/342486/creating-a-simple-dzerclink-between-two-new-parameters/p1 )

Controlling a slider on the Surfaces tab from a slider on the Parameters tab is not (usually) a problem either ( https://www.daz3d.com/forums/discussion/341521/creating-dependencies-between-settings-on-the-surfaces-tab-and-parameters-tab/p1 )

But I now find myself wanting to control a Morph slider from a Parameters slider, and  I'd assumed that the morph slider would be just another Dzproperty.
But despite the morph showing on the Parameters tab...

...I can't seem to access it in the same way as other parameters.
E.g.. the following gives me '13 Chip MT' NOT FOUND

		var aNodes = Scene.getSelectedNodeList();		...		oNode = aNodes[0];		...		if( findElementProperty( oNode, "13 Chip MT" ) ) showAlert( "'13 Chip MT' already exists" );		else  showAlert( "'13 Chip MT' NOT FOUND" );		...

 

As usual, it's highly likely that I'm missing something obvious/doing something stupid.
Which is why I'm asking.

 

P.S. findElementProperty() is a function/method/whatever-you-call-it from this sample  http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/elements/post_load_material_proxy_create/start (that link doesn't seem to work, but if you copy the URL and paste it goes to the right place,and gets a 'not found' because they've changed the darn URL!)

whatIwant.jpg
551 x 339 - 28K
Post edited by 3dcheapskate on

Comments

  • Using this, which is basically the code from findElementProperty() , but printing each propertyname...

    			var oProperty;			var oPropertyGroupTree = oNode.getPropertyGroups();			var oPropertyGroup = oPropertyGroupTree.getFirstChild();			var aProperties = [];			if( oPropertyGroup ){				var nProperties = oPropertyGroup.getNumProperties();				aProperties = new Array( nProperties );				for( var i = 0; i < nProperties; i += 1 )					aProperties[ i ] = oPropertyGroup.getProperty( i );				aProperties = aProperties.concat( getGroupProperties( oPropertyGroup.getFirstChild() ) );				aProperties = aProperties.concat( getGroupProperties( oPropertyGroup.getNextSibling() ) );			} 			for( var i = 0; i < aProperties.length; i += 1 ){				oProperty = aProperties[i];				print(oProperty.name)			}

    ...I get this...

    2020-02-19 15:46:04.142 DEBUG: >>>ALERT:'13 Chip MT' NOT FOUND
    2020-02-19 15:46:04.142 DEBUG: XTranslate
    2020-02-19 15:46:04.142 DEBUG: YTranslate
    2020-02-19 15:46:04.142 DEBUG: ZTranslate
    2020-02-19 15:46:04.142 DEBUG: XRotate
    2020-02-19 15:46:04.142 DEBUG: YRotate
    2020-02-19 15:46:04.142 DEBUG: ZRotate
    2020-02-19 15:46:04.142 DEBUG: Scale
    2020-02-19 15:46:04.142 DEBUG: XScale
    2020-02-19 15:46:04.142 DEBUG: YScale
    2020-02-19 15:46:04.142 DEBUG: ZScale
    2020-02-19 15:46:04.142 DEBUG: Point At
    2020-02-19 15:46:04.142 DEBUG: Disable Transform
    2020-02-19 15:46:04.142 DEBUG: Geometry
    2020-02-19 15:46:04.142 DEBUG: lodlevel
    2020-02-19 15:46:04.142 DEBUG: SubDIALevel
    2020-02-19 15:46:04.142 DEBUG: SubDRenderLevel
    2020-02-19 15:46:04.142 DEBUG: SubDAlgorithmControl
    2020-02-19 15:46:04.142 DEBUG: SubDEdgeInterpolateLevel
    2020-02-19 15:46:04.142 DEBUG: SubDNormalSmoothing
    2020-02-19 15:46:04.142 DEBUG: Visible
    2020-02-19 15:46:04.142 DEBUG: Visible in Viewport
    2020-02-19 15:46:04.142 DEBUG: Selectable
    2020-02-19 15:46:04.142 DEBUG: Renderable
    2020-02-19 15:46:04.142 DEBUG: Cast Shadows
    2020-02-19 15:46:04.142 DEBUG: Render Priority
    2020-02-19 15:46:04.142 DEBUG: Visible in Simulation
    2020-02-19 15:46:04.142 DEBUG: Value
    2020-02-19 15:46:04.142 DEBUG: Total Number Of Chips
    2020-02-19 15:46:04.142 DEBUG: Vertical Tiles
    2020-02-19 15:46:04.142 DEBUG: Intermediate Chip Count
    2020-02-19 15:46:04.142 DEBUG: Value For Vertical Tiling
    2020-02-19 15:46:04.142 DEBUG: Intermediate Chip Count Minus One
    2020-02-19 15:46:04.142 DEBUG: Value For Stack Height Morph
    2020-02-19 15:46:04.142 DEBUG: 3DCheapskate's 'AddMy4ParametersWith2ERC.dsa' Script - completed without crashing ! Hurrah !

    No '13 Chip MT' in sight.

  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    Looking at the object index to work out what object I should be looking at is, for me, like doing oneof those "Where's Wally" puzzle pictures.

    But without knowing what Wally looks like.

    Post edited by 3dcheapskate on
  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    One obvious-ish place to start is by searching the object index for 'morph'.
    Only three - DzMorphLoader, DzMorphLoaderBatch, DzMorphSupportAssetFilter.
    Can't see anything to help me there.
    But would I recognize something helpful if I saw it ?

    How about the sample scripts?
    Two with the word 'morph' - Save Morph Asset(s) and Silent OBJ Morph Loader Import
    Can't see anything to help me there either.

    Ho hum.

     

    Edit:tantalizingly, DzMorphLoader has stuff like setControlPropertyERCCustomValue() and setMorphName() which make me think that it must be here somewhere...

    Post edited by 3dcheapskate on
  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    Hmmm... I'd guess that morphs are related to geometry more than nodes.

    And I think I recall a DzShape (introduced around DS4.5/4.6?) that never got documented in the object index - I think it's used in some of the sample scripts. And I'm fairly sure I've used it before, but not in relation to morphs.

    Oh gawd ! Object Obfuscation !

    Post edited by 3dcheapskate on
  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    Okay, I've found a bit of code where I needed to look at a DzShape:

    	...	// Get the geometry name and vertex count	sGeom=""	sNumVert=""	oPropObj = nProp.getObject()	if (oPropObj){		oShape = oPropObj.getCurrentShape()		if (oShape){			oGeom = oShape.getGeometry()			if (oGeom){				sGeom=oGeom.name				sNumVert = oGeom.getNumVertices()			} else print ("No oGeom");		} else print ("No oShape");	} else print ("No oPropObj");	...	

    nProp is a node.

    Post edited by 3dcheapskate on
  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    Ha !

    Got it ! Via the 'getNumModifiers()' and 'getModifier(#)' methods of a DzObject

    			oPropObj = oNode.getObject()			if (oPropObj){				print("oPropObj="+oPropObj.name);				n=oPropObj.getNumModifiers()				for(i=0;i<n;i++){					modi=oPropObj.getModifier(i)					print("modifier "+i+"name = "+modi.name)				}				oShape = oPropObj.getCurrentShape();				if (oShape){					print("oShape="+oShape.name);				}else print("No oShape");			} else print("No oPropObj");

    ...outputs

    ...

    2020-02-19 19:28:37.938 DEBUG: Value For Vertical Tiling
    2020-02-19 19:28:37.938 DEBUG: Intermediate Chip Count Minus One
    2020-02-19 19:28:37.938 DEBUG: Value For Stack Height Morph
    2020-02-19 19:28:37.938 DEBUG: oPropObj=ForDSimport_98
    2020-02-19 19:28:38.000 DEBUG: modifier 0name = 13 Chip MT
    2020-02-19 19:28:38.016 DEBUG: oShape=shape
    2020-02-19 19:28:38.016 DEBUG: 3DCheapskate's 'AddMy4ParametersWith2ERC.dsa' Script - completed without crashing ! Hurrah !

     

    So a morph is a modifier on an object on a prop node !
    As obvious as Wally in a "Where's Wally" picture - i.e. when you know the answer already, it's easy.

    Post edited by 3dcheapskate on
  • Next part - can I slave a morph to a normal parameter (and assuming that I can, then how doI do it?)

  • Morph are DzModifier derivatives (DzMorphModifier, which isn't currently linked in the docs), and belong to the geometry as you say. You need to use the findModifier( name ) or getModifier( # ) and related methods as I recall.

    Grab the old DS 3 scripting docs as the outline at least is in them.

  • Thanks Richard. I think I just beat you to it - although I wouldn't have worked out that there was an undocumented DzMorphModifer ! laugh

  • 3dcheapskate3dcheapskate Posts: 2,719
    edited February 2020

    Anyway, to continue with the ERC part of the query.

    The ERCLink constructor requires a DzNumericProperty as the controller, and the slave has to have an insertController() method. This is the sort of thing I've currently got,slaving on DzProperty to another DzProperty:

         oERCLink = new DzERCLink( DzERCLink.ERCAdd, oIntChipCntProperty ); //Set up the controller     oIntChipCntMinusOneProperty.insertController(oERCLink); // Set the slave

     

    So the question is, does a DzModifier have an insertController() method ?
    Time for this software monkey to go climb the DAZ Script Object hierarchy tree...

    ...already found a DzNumericProperty.insertController() banana.

    The morph is controlled by a slider, and that slider must be associated with a DzNumericProperty, yes ? So it should just be a case of finding that.
    There's no DzNumericProperty declared in DzModifier
    But next branch up the hierarchy is DzElement, which has methods such as addProperty() and findPropertyByLabel().

     

    Adding an extra bit of chewing gum to that scrip snippet...

    			oPropObj = oNode.getObject()			if (oPropObj){				print("oPropObj="+oPropObj.name);				n=oPropObj.getNumModifiers()				for(i=0;i<n;i++){					modi=oPropObj.getModifier(i)					print("modifier "+i+"name = "+modi.name)					pl=modi.getPropertyList()					np=modi.getNumProperties()					print(modi.name+" np = "+ np)					for(j=0;j<np;j++){						print(modi.name+" property "+j+": "+pl[j].name)					}				}				oShape = oPropObj.getCurrentShape();				if (oShape){					print("oShape="+oShape.name);				}else print("No oShape");			} else print("No oPropObj");

     

    ...indicates that my DzModifier has a single property, 'Value'. That sounds vaguely promising.

     

    ...

    2020-02-19 20:11:46.930 DEBUG: Intermediate Chip Count Minus One
    2020-02-19 20:11:46.930 DEBUG: Value For Stack Height Morph
    2020-02-19 20:11:46.930 DEBUG: oPropObj=ForDSimport_98
    2020-02-19 20:11:46.930 DEBUG: modifier 0name = 13 Chip MT
    2020-02-19 20:11:46.930 DEBUG: 13 Chip MT np = 1
    2020-02-19 20:11:46.930 DEBUG: 13 Chip MT property 0: Value

    2020-02-19 20:11:46.930 DEBUG: oShape=shape
    2020-02-19 20:11:46.930 DEBUG: ALL DONE
    2020-02-19 20:11:46.930 DEBUG: 3DCheapskate's 'AddMy4ParametersWith2ERC.dsa' Script - completed without crashing ! Hurrah !

    Post edited by 3dcheapskate on
  • The excitement's too much for me to bear ! I'm going to stop for this evening. Probably

  • Try oModifier.getValueChannel(), from memory.

  • Thanks Richard, I can now read/set the morph value, using this code which is a slightly adjusted bit from that Node Property sample script:

    		 			// Get the properties available to the user by way of the selected node			var aProperties = getElementProperties( oNode, true, true );			// Declare variables we'll be using as we iterate			var oProperty, oOwner, oPresentation;			// Iterate over all properties			for( var i = 0; i < aProperties.length; i += 1 ){				// Get the "current" property				oProperty = aProperties[ i ];				// Get the owner of the property				oOwner = oProperty.getOwner();		 				// If the property is on the node itself 				if( inheritsType( oOwner, ["DzNode"] ) ){					print("NODE PROPERTY: "+oProperty.name)				// If the property is on a morph 				} else if( inheritsType( oOwner, ["DzMorph"] ) ){					print("- MORPH PROPERTY: "+oProperty.name+" is set to "+oProperty.getValue())					oProperty.setValue(0.321)					print("- MORPH PROPERTY: "+oProperty.name+" is reset to "+oProperty.getValue())				// If the property is on another element 				} else {					print("- MISCELLANEOUS PROPERTY: "+oProperty.name)				}			}

    Running it I get:

    ...
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: ZScale
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Point At
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Disable Transform
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: Geometry
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: lodlevel
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: SubDIALevel
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: SubDRenderLevel
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: SubDAlgorithmControl
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: SubDEdgeInterpolateLevel
    2020-02-20 18:00:24.854 DEBUG: - MISCELLANEOUS PROPERTY: SubDNormalSmoothing
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Visible
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Visible in Viewport
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Selectable
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Renderable
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Cast Shadows
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Render Priority
    2020-02-20 18:00:24.854 DEBUG: NODE PROPERTY: Visible in Simulation
    2020-02-20 18:00:24.854 DEBUG: - MORPH PROPERTY: Value is set to 1.0466502904891968
    2020-02-20 18:00:24.864 DEBUG: - MORPH PROPERTY: Value is reset to 0.32100000977516174

    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Total Number Of Chips
    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Vertical Tiles
    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Intermediate Chip Count
    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Value For Vertical Tiling
    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Intermediate Chip Count Minus One
    2020-02-20 18:00:24.864 DEBUG: NODE PROPERTY: Value For Stack Height Morph
    2020-02-20 18:00:26.129 DEBUG: >>>ALERT:Done new DzMorph bit.
    2020-02-20 18:00:26.129 DEBUG: ALL DONE
    2020-02-20 18:00:26.129 DEBUG: 3DCheapskate's 'AddMy4ParametersWith2ERC.dsa' Script - completed without crashing ! Hurrah !

     

  • You need the name of the morph, the owner, rather than the numeric property that controls it - oOwner.name. The property will give you the label, however, if you want to work with the proeprty in order to generalise.

Sign In or Register to comment.