help with a script idea (IOR value insert) , and I no idea how to write one
StratDragon
Posts: 3,245
I made a list of IOR values and the material names. I would like to create a script that lists the names and the values that allows the opperator to select the value and it will change only the IOR value in whatever shader you have. Can this be done? Is this aready done? Does no one want this done? thank you.
Post edited by Richard Haseltine on
Comments
Moved to the Script Development forum since it si not an offer of a freebie.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/material_properties/start shows how to access material properties, several other scripts in http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/start#properties show how to manipulate properties.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general_ui/simple_dialog/start shows how to build a simple dialogue
If you use sections of there make sure you respect the the CC 3 license terms, as linked from each page, should you wish to share the results.
thanks!
for clarity I asked chatgpt to write this for me but I get Script Error:
Line 53 TypeError: Result of expression 'Scene.getSelectedNodes' [undefined] is not a function.
Stack Trace: ()@:53
I've asked chat gpt to find and fix the error but it has not been successful. based on the original ask in this thread can anyone see what is the point(s) of failure?
Well, trusting ChatGPT....
Specifically, check the things it is doing - if you go to DzScene http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/scene_dz then you will see that indeed there is no getSelectedNodes() method, What there is is a getSelctedNodeList method http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/scene_dz#a_1aed50f135a75070c3a9a06e851e97941f
You might also want to look at DzNode, which has no getSurface( index ) or isMesh members so the script would fail there too. Nor does DzMaterial have a function for settings an IoR - that is not a basic feature, you would need instead to find the proeprty using the emthod for the base DzElement, and you woiuld need to get the nodes shape to get its materials in the first place.
At least ChatGPT got soemthing like the correct format (in the past it has produced Python scripts) but it is still confabulating, inventing methods to match the general pattern of the scripts it has digested and the names that are triggered by the prompt - it has no actual knowledge on which to build and is incapable of any kind of critical evaluation of its output.
Sorry to beat this at length, but if you want soemthing that hasn't already been done - with slight variantions - multiple times before you are unlikely to get usable code out of generative AI.
truth be told, I'm not a fan of AI, but one forum suggested it, I figured I'd give it a shot. thanks again.
Current chatgpt knows javascript very well, but not specifically DAZ script and its functions. It will get you 75% of the way there, the rest is on you to make sure the code looks good and works. Reading and troubleshooting code will be required.