Setting Simulation Properties Under the Surfaces Tab Via Script
The following code is an old snippet that I've used in the past to set material properties. In this case, it never enters if( prop ), but works fine if I change "Dynamics Strength" to "Opacity Strength".
Anybody know if simulation properties under the surface tab need to be set a different way than normal material properties?
Thanks in advance if anybody knows.
- Greg
var nodes = Scene.getSelectedNodeList();
var n = nodes.length;
for( var i = 0; i < n; i++ )
{
var obj = nodes[i].getObject();
if( obj )
{
var nShapes = obj.getNumShapes();
for( var j = 0; j < nShapes; j++ )
{
var shape = obj.getShape( j );
var nMats = shape.getNumMaterials();
for( k = 0; k < nMats; k++ )
{
var mat = shape.getMaterial( k );
if (mat.getLabel()=="1")
{
var prop = mat.findPropertyByLabel( "Dynamics Strength" );
if( prop )
{
prop.setValue( .99 );
}
}
}
}
}
}
Comments
I think simulation properties in the Surfaces pane are not materials but modifiers. I'll check later.
You may want to try seeing if the surface has the dForce modifier first, before checking for the Dynamics strength setting. Unfortunately, I'm not sure how to do that.
Thanks for taking the time to respond. I'll try to access it as a modifier and post back.
- Greg
In this case, I'm positive the surface had a dForce modifier. I think jag is probably correct - will post back as soon as I get a chance to try it.
Thanks for taking the time to chime in - I appreciate it.
- Greg
Finally I was able to reach the simulation properties under Surfaces pane, although these properties should have their own "Simulation pane".
All simulation properties are accessible in a class named DzDForceSettingsProvider, but only if the node has the DzDForceModifier modifier applied.
First you need a shape object from the node: node.getObject().getCurrentShape()
The current shape is a DzFacetShape class that has two new methods, getSimulationProviderNames() and findSimulationSettingsProvider(providerName), in the tests I made providerName was the same as the material name.
Once you have a simulation settings provider, you use the methods get#####Control
Here is the class you get by findSimulationSettingsProvider:
HTH
P.S. I did'nt provide code 'cause right now looks like italian spaghetti.
See the Material Properties sample.
-Rob
Thanks for taking the time to do this legwork and post, jag!
- Greg
Fantastic. I was able to set the Dynamics Strength with a modified version of this example.
I know you're extremely busy, Rob. I truly appreciate you taking the time - thank you.
- Greg
ETA: dForce is awesome!
Thanks .
I'm interested - сan I do button " Simulate" in daz script GUI ?
Not on a box with DS installed atm, but check out this post from Rob:
https://www.daz3d.com/forums/discussion/comment/1546026/#Comment_1546026
Hope this helps.
- Greg
Thank you very much :). Working function for Simulation Button
For "Add dForce Modifier: Dynamic Surface"