Script to set mesh resolution?

Hi everyone,

I currently have a script that will allow me to toggle visibility on a node.  This script uses 
var oSomething1 = Scene.findNodeByLabel("Some Node In The Scene");

oSomething1.setVisible( !oSomething1.isVisible() );

I'd like to adapt this to set resolution from Base to High, and back again.  Obviously "setVisible" won't work.  But I can't (out of brute ignorance) find the -- method, function, what-have-you -- to replace ".setVisible".  I am not a coder by any stretch, so please if you take the time to answer, talk to me like I'm five.

Thanks in advance!

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,948

    Couldn't you just use a Properties preset? If you do need to do it via script, see http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start where Mesh Resolution is one of the examples used

  • crosswindcrosswind Posts: 6,986

    Similar script that I wrote with checking Content Type as well, in this thread - https://forum.daz3d.com/forums/discussion/668781/is-there-a-script-that-can-change-all-wearable-resolution

    Maybe you can give it a check and change the content type accordingly as you want.

  • OmnifluxOmniflux Posts: 377

    Nodes may have more than two levels of detail, so this switches through each value instead of just "Base" and "High Resolution"...

    If you know the two values you want to work with are always named "Base" and "High", you can check if getStringValue() == 'Base' and then use setValueFromString() as appropriate instead, and skip any other values the node has. These methods are on the DzEnumProperty, oLODControl in this example.

    // Switch to next Level of Detail on selected node.//// Author: Omniflux// Version: 1// Date: 2024-03-09(function() {	function nextLOD(oNode) {		if (oNode.inherits('DzBone'))			oNode = oNode.getSkeleton();		try {			oLODControl = oNode.getObject().getCurrentShape().getLoDControl();			oLODControl.setValue((oLODControl.getValue() + 1) % (oLODControl.getMax() + 1));		}		catch (e) {			if (e instanceof TypeError)				MessageBox.critical("%1 does not have LoD".arg(oNode.getLabel()), "Failed to change LoD", qsTr ("&OK"));			else				MessageBox.critical(e, "Failed to change LoD", qsTr ("&OK"));		}	}	beginUndo();	nextLOD(Scene.getPrimarySelection());	acceptUndo('Switch LoD');})();

     

    dsa
    dsa
    Next LoD.dsa
    756B
  • crosswindcrosswind Posts: 6,986

    @Omniflux  That's great ! Thank you for the instruction ! yes

  • Causam3DCausam3D Posts: 212

    Thanks for the help everyone, as always the answer is to be found here if nowhere else.

Sign In or Register to comment.