Setting Simulation Properties Under the Surfaces Tab Via Script

algovincianalgovincian Posts: 2,576

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 );
                    }
                }
            }
        }
    }
}

Post edited by algovincian on

Comments

  • jag11jag11 Posts: 885

    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.

  • algovincianalgovincian Posts: 2,576
    jag11 said:

    I think simulation properties in the Surfaces pane are not materials but modifiers. I'll check later.

    Thanks for taking the time to respond. I'll try to access it as a modifier and post back.

    - Greg

  • algovincianalgovincian Posts: 2,576

    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.

    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

  • jag11jag11 Posts: 885

    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:

    declare class DzDForceSettingsProvider {objectName: string; // DZ__SPS_Defaultname: string; // DZ__SPS_DefaultelementID: number; // 725assetUri: object; // #DZ__SPS_DefaultassetSource: object; // assetId: string; // DZ__SPS_DefaultassetAuthor: object; // ["","",""]assetFileRevision: object; // 0.0.0.0assetModifiedDate: object; // Invalid Datedestroyed(QObject*): any;destroyed(): any;deleteLater(): any;nameChanged(QString): any;className(): any;makePersistent(): any;inherits(QString): any;iskindof(QString): any;getName(): any;propertyAdded(DzProperty*): any;propertyRemoved(DzProperty*): any;propertyListChanged(): any;propertyListInTreeChanged(): any;propertyTreeChanged(): any;privatePropertyAdded(DzProperty*): any;privatePropertyRemoved(DzProperty*): any;privatePropertyListChanged(): any;privatePropertyListInTreeChanged(): any;privatePropertyTreeChanged(): any;labelChanged(QString): any;parentChanged(): any;mergeElementSignal(const DzElement*,DzElementDuplicateContext*): any;duplicateElementSignal(DzElement*,DzElementDuplicateContext*): any;createElementCopySignal(DzElementDuplicateContext*): any;setAttributes(const DzSettings*): any;setName(QString): any;setLabel(QString): any;update(): any;clearAnimData(DzTimeRange): any;clearAllAnimData(): any;addProperty(DzProperty*): any;insertProperty(int,DzProperty*): any;removeProperty(DzProperty*): any;removeProperty(QString): any;moveProperty(DzProperty*,DzElement*): any;addPrivateProperty(DzProperty*): any;insertPrivateProperty(int,DzProperty*): any;removePrivateProperty(DzProperty*): any;removePrivateProperty(QString): any;movePrivateProperty(DzProperty*,DzElement*): any;addDataItem(DzElementData*): any;removeDataItem(DzElementData*): any;deleteDataItem(DzElementData*): any;copyFrom(const DzElement*): any;setLoadScript(DzScript*): any;beginEdit(): any;finishEdit(): any;cancelEdit(): any;shouldSortOnLoad(): any;getLabel(): any;getAttributes(DzSettings*): any;getNumProperties(): any;getProperty(int): any;getPropertyList(): any;isPropertyNameUnique(QString&amp;,bool): any;isPropertyNameUnique(QString&amp;): any;getUniquePropertyName(QString): any;findProperty(QString): any;findProperty(QString,bool): any;findPropertyByLabel(QString): any;findPropertyByLabel(QString,bool): any;getPropertyGroups(): any;findMatchingProperty(DzProperty*): any;getNumPrivateProperties(): any;getPrivateProperty(int): any;getPrivatePropertyList(): any;isPrivatePropertyNameUnique(QString&amp;,bool): any;isPrivatePropertyNameUnique(QString&amp;): any;getUniquePrivatePropertyName(QString): any;findPrivateProperty(QString): any;findPrivateProperty(QString,bool): any;findPrivatePropertyByLabel(QString): any;findPrivatePropertyByLabel(QString,bool): any;getPrivatePropertyGroups(): any;getNumDataItems(): any;getDataItem(int): any;getDataItemList(): any;isDataItemNameUnique(QString&amp;,bool): any;isDataItemNameUnique(QString&amp;): any;getUniqueDataItemName(QString): any;findDataItem(QString): any;getLoadScript(): any;copyToClipboard(QStringList): any;copyToClipboard(): any;getNumElementChildren(): any;getElementChild(int): any;getElementParent(): any;inEdit(): any;moveDataItemToIndex(DzElementData*,int): any;findDataItemIndex(DzElementData*): any;duplicateMissingCustomData(DzElement*): any;duplicateMissingProperties(DzElement*): any;duplicateMissingPrivateProperties(DzElement*): any;duplicateMissingCustomDataWithContext(DzElement*,DzElementDuplicateContext*): any;duplicateMissingPropertiesWithContext(DzElement*,DzElementDuplicateContext*): any;duplicateMissingPrivatePropertiesWithContext(DzElement*,DzElementDuplicateContext*): any;doMergeElement(const DzElement*,DzElementDuplicateContext*): any;doDuplicateElement(DzElementDuplicateContext*): any;mergeElement(const DzElement*,DzElementDuplicateContext*): any;duplicateElement(DzElement*,DzElementDuplicateContext*): any;createElementCopy(DzElementDuplicateContext*): any;assetModified(): any;assetWasSaved(): any;settingsChanged(): any;shapeChanged(DzShape*,DzShape*): any;modifyAsset(): any;modifyAsset(DzUri): any;shouldAlwaysEmbed(): any;duplicateProvider(DzElementDuplicateContext*): any;getShape(): any;getVisibleInSimulationControl(): any;getFrictionControl(): any;getSimulationTypeControl(): any;getDynamicsStrengthControl(): any;getStretchStiffnessControl(): any;getShearStiffnessControl(): any;getCompressionResistanceControl(): any;getBendStiffnessControl(): any;getBucklingStiffnessControl(): any;getBucklingRatioControl(): any;getDensityControl(): any;getDampingControl(): any;getStretchDampingControl(): any;getShearDampingControl(): any;getBendDampingControl(): any;getContractionExpansionRatioControl(): any;getCollisionLayerControl(): any;getCollideControl(): any;getSelfCollideControl(): any;getCollisionOffsetControl(): any;getVelocitySmoothingWeightControl(): any;getVelocitySmoothingIterationsControl(): any;getSurfaceSmoothingWeightControl(): any;getSurfaceSmoothingIterationsControl(): any;getVisibleInSimulation(): any;setVisibleInSimulation(bool): any;getFriction(): any;setFriction(float): any;getSimulationType(): any;setSimulationType(SimulationType): any;getDynamicsStrength(): any;setDynamicsStrength(float): any;getStretchStiffness(): any;setStretchStiffness(float): any;getShearStiffness(): any;setShearStiffness(float): any;getCompressionResistance(): any;setCompressionResistance(float): any;getBendStiffness(): any;setBendStiffness(float): any;getBucklingStiffness(): any;setBucklingStiffness(float): any;getBucklingRatio(): any;setBucklingRatio(float): any;getDensity(): any;setDensity(float): any;getDamping(): any;setDamping(float): any;getStretchDamping(): any;setStretchDamping(float): any;getShearDamping(): any;setShearDamping(float): any;getBendDamping(): any;setBendDamping(float): any;getContractionExpansionRatio(): any;setContractionExpansionRatio(float): any;getCollisionLayer(): any;setCollisionLayer(int): any;getCollide(): any;setCollide(bool): any;getSelfCollide(): any;setSelfCollide(bool): any;getCollisionOffset(): any;setCollisionOffset(float): any;getVelocitySmoothingWeight(): any;setVelocitySmoothingWeight(float): any;getVelocitySmoothingIterations(): any;setVelocitySmoothingIterations(int): any;getSurfaceSmoothingWeight(): any;setSurfaceSmoothingWeight(float): any;getSurfaceSmoothingIterations(): any;setSurfaceSmoothingIterations(int): any;inherits(): any;className(): any;}

    HTH

    P.S. I did'nt provide code 'cause right now looks like italian spaghetti.

     

  • rbtwhizrbtwhiz Posts: 2,179
    edited November 2017

    See the Material Properties sample.

    -Rob

    Post edited by rbtwhiz on
  • algovincianalgovincian Posts: 2,576
    jag11 said:

    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:

    declare class DzDForceSettingsProvider {objectName: string; // DZ__SPS_Defaultname: string; // DZ__SPS_DefaultelementID: number; // 725assetUri: object; // #DZ__SPS_DefaultassetSource: object; // assetId: string; // DZ__SPS_DefaultassetAuthor: object; // ["","",""]assetFileRevision: object; // 0.0.0.0assetModifiedDate: object; // Invalid Datedestroyed(QObject*): any;destroyed(): any;deleteLater(): any;nameChanged(QString): any;className(): any;makePersistent(): any;inherits(QString): any;iskindof(QString): any;getName(): any;propertyAdded(DzProperty*): any;propertyRemoved(DzProperty*): any;propertyListChanged(): any;propertyListInTreeChanged(): any;propertyTreeChanged(): any;privatePropertyAdded(DzProperty*): any;privatePropertyRemoved(DzProperty*): any;privatePropertyListChanged(): any;privatePropertyListInTreeChanged(): any;privatePropertyTreeChanged(): any;labelChanged(QString): any;parentChanged(): any;mergeElementSignal(const DzElement*,DzElementDuplicateContext*): any;duplicateElementSignal(DzElement*,DzElementDuplicateContext*): any;createElementCopySignal(DzElementDuplicateContext*): any;setAttributes(const DzSettings*): any;setName(QString): any;setLabel(QString): any;update(): any;clearAnimData(DzTimeRange): any;clearAllAnimData(): any;addProperty(DzProperty*): any;insertProperty(int,DzProperty*): any;removeProperty(DzProperty*): any;removeProperty(QString): any;moveProperty(DzProperty*,DzElement*): any;addPrivateProperty(DzProperty*): any;insertPrivateProperty(int,DzProperty*): any;removePrivateProperty(DzProperty*): any;removePrivateProperty(QString): any;movePrivateProperty(DzProperty*,DzElement*): any;addDataItem(DzElementData*): any;removeDataItem(DzElementData*): any;deleteDataItem(DzElementData*): any;copyFrom(const DzElement*): any;setLoadScript(DzScript*): any;beginEdit(): any;finishEdit(): any;cancelEdit(): any;shouldSortOnLoad(): any;getLabel(): any;getAttributes(DzSettings*): any;getNumProperties(): any;getProperty(int): any;getPropertyList(): any;isPropertyNameUnique(QString&amp;,bool): any;isPropertyNameUnique(QString&amp;): any;getUniquePropertyName(QString): any;findProperty(QString): any;findProperty(QString,bool): any;findPropertyByLabel(QString): any;findPropertyByLabel(QString,bool): any;getPropertyGroups(): any;findMatchingProperty(DzProperty*): any;getNumPrivateProperties(): any;getPrivateProperty(int): any;getPrivatePropertyList(): any;isPrivatePropertyNameUnique(QString&amp;,bool): any;isPrivatePropertyNameUnique(QString&amp;): any;getUniquePrivatePropertyName(QString): any;findPrivateProperty(QString): any;findPrivateProperty(QString,bool): any;findPrivatePropertyByLabel(QString): any;findPrivatePropertyByLabel(QString,bool): any;getPrivatePropertyGroups(): any;getNumDataItems(): any;getDataItem(int): any;getDataItemList(): any;isDataItemNameUnique(QString&amp;,bool): any;isDataItemNameUnique(QString&amp;): any;getUniqueDataItemName(QString): any;findDataItem(QString): any;getLoadScript(): any;copyToClipboard(QStringList): any;copyToClipboard(): any;getNumElementChildren(): any;getElementChild(int): any;getElementParent(): any;inEdit(): any;moveDataItemToIndex(DzElementData*,int): any;findDataItemIndex(DzElementData*): any;duplicateMissingCustomData(DzElement*): any;duplicateMissingProperties(DzElement*): any;duplicateMissingPrivateProperties(DzElement*): any;duplicateMissingCustomDataWithContext(DzElement*,DzElementDuplicateContext*): any;duplicateMissingPropertiesWithContext(DzElement*,DzElementDuplicateContext*): any;duplicateMissingPrivatePropertiesWithContext(DzElement*,DzElementDuplicateContext*): any;doMergeElement(const DzElement*,DzElementDuplicateContext*): any;doDuplicateElement(DzElementDuplicateContext*): any;mergeElement(const DzElement*,DzElementDuplicateContext*): any;duplicateElement(DzElement*,DzElementDuplicateContext*): any;createElementCopy(DzElementDuplicateContext*): any;assetModified(): any;assetWasSaved(): any;settingsChanged(): any;shapeChanged(DzShape*,DzShape*): any;modifyAsset(): any;modifyAsset(DzUri): any;shouldAlwaysEmbed(): any;duplicateProvider(DzElementDuplicateContext*): any;getShape(): any;getVisibleInSimulationControl(): any;getFrictionControl(): any;getSimulationTypeControl(): any;getDynamicsStrengthControl(): any;getStretchStiffnessControl(): any;getShearStiffnessControl(): any;getCompressionResistanceControl(): any;getBendStiffnessControl(): any;getBucklingStiffnessControl(): any;getBucklingRatioControl(): any;getDensityControl(): any;getDampingControl(): any;getStretchDampingControl(): any;getShearDampingControl(): any;getBendDampingControl(): any;getContractionExpansionRatioControl(): any;getCollisionLayerControl(): any;getCollideControl(): any;getSelfCollideControl(): any;getCollisionOffsetControl(): any;getVelocitySmoothingWeightControl(): any;getVelocitySmoothingIterationsControl(): any;getSurfaceSmoothingWeightControl(): any;getSurfaceSmoothingIterationsControl(): any;getVisibleInSimulation(): any;setVisibleInSimulation(bool): any;getFriction(): any;setFriction(float): any;getSimulationType(): any;setSimulationType(SimulationType): any;getDynamicsStrength(): any;setDynamicsStrength(float): any;getStretchStiffness(): any;setStretchStiffness(float): any;getShearStiffness(): any;setShearStiffness(float): any;getCompressionResistance(): any;setCompressionResistance(float): any;getBendStiffness(): any;setBendStiffness(float): any;getBucklingStiffness(): any;setBucklingStiffness(float): any;getBucklingRatio(): any;setBucklingRatio(float): any;getDensity(): any;setDensity(float): any;getDamping(): any;setDamping(float): any;getStretchDamping(): any;setStretchDamping(float): any;getShearDamping(): any;setShearDamping(float): any;getBendDamping(): any;setBendDamping(float): any;getContractionExpansionRatio(): any;setContractionExpansionRatio(float): any;getCollisionLayer(): any;setCollisionLayer(int): any;getCollide(): any;setCollide(bool): any;getSelfCollide(): any;setSelfCollide(bool): any;getCollisionOffset(): any;setCollisionOffset(float): any;getVelocitySmoothingWeight(): any;setVelocitySmoothingWeight(float): any;getVelocitySmoothingIterations(): any;setVelocitySmoothingIterations(int): any;getSurfaceSmoothingWeight(): any;setSurfaceSmoothingWeight(float): any;getSurfaceSmoothingIterations(): any;setSurfaceSmoothingIterations(int): any;inherits(): any;className(): any;}

    HTH

    P.S. I did'nt provide code 'cause right now looks like italian spaghetti.

    Thanks for taking the time to do this legwork and post, jag! 

    - Greg

  • algovincianalgovincian Posts: 2,576
    edited November 2017
    rbtwhiz said:

    See the Material Properties sample.

    -Rob

    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!

    Post edited by algovincian on
  • YudinEdYudinEd Posts: 90
    edited November 2017
    jag11 said:

     

    .....Here is the class you get by findSimulationSettingsProvider:

    ...

    Thanks . 

    I'm interested - сan I do button " Simulate" in daz script GUI ?

    Post edited by YudinEd on
  • algovincianalgovincian Posts: 2,576
    YudinEd said:
    jag11 said:

     

    .....Here is the class you get by findSimulationSettingsProvider:

    ...

    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

  • YudinEdYudinEd Posts: 90
    edited November 2017

    Thank you very much :). Working function for Simulation Button 

    var mgr = MainWindow.getActionMgr();func = mgr.findAction( "DzSimulateAction" )if( !func ){return;}func.trigger();

     

    For "Add dForce Modifier: Dynamic Surface"

    var mgr = MainWindow.getActionMgr();func = mgr.findAction( "DzAddDForceModifierDynamicSurfaceAction" )if( !func ){return;}func.trigger();

     

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