[Solved] Adding a Smoothing modifier
meipe
Posts: 101
Do anyone know if there is a way to add a smoothing modifier by script?
Post edited by meipe on
Comments
I don't, and the various modifier objects are not yet documented http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/modifier_dz . Dz Object has an AddModifier( modifier ) method, but to use that you'd need to be able to create a new Smoothing Modifier which would probably be a method of meshsmoothmodifier_dz.
Well, mod = new DzSmoothModifier() works and it's possible to run Rob's discovery trick on it:
whicxh yields a promising list of properties.
However,
errors out on the last line so it obviously needs more than just a raw item. I'm an idiot - it was AddModifier instead of addModifier in the code, correcting that and it works as expected. So, two ways of doing it - but Rob's is the officially recommended.
Rob says use http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/actions/action_trigger/start to trigger "DzMeshSmoothAction"
At the risk of turning this into a monologue I'm going to add another post rather than try editing again since I seem to be extra typo-prone tonight.
If you want to take the bare-wires-on-a-bread-board snippet above rather than use Rob's code (where the action will do most of the error checking for the script in compiled code) then you will need to add a lot of error checking. Not just the usual stuff (that a node has been passed, though preferably - if this is getting selected nodes from the scene at all - you'd get and use all the selected nodes, getting the skeleton for any bones passed, and checking for dupes) but you'd also need to check that each node did in fact have an object, and if it did you'd need to check its modifier list for any that inherited DzMeshSmoothModifier (if you saw my previous edit I had that down as DzModifier, which was of course totally wrong) snce each mesh can have only one Smoothing Modifier. You'd also need to check the return from the addModifier() method, and before that that the modifier was actually created, so quite a lot of overhead to add compared to just triggering an action which would be executed by compiled code.
Thanks a lot to both... It works like a charm, both ways. I see your point about using Rob's code...
I tried to run your four lines of code twice (instead of Rob's action trigger using DzMeshSmoothAction), on a primitive, and I see no noticeable issue the second time. It looks like DAZ Studio is safely ignoring it, if there already is a smooting modifier on the object.
Ok, just linking to Rob's script that allows to enumerate all actions that can be triggered in DAZ Studio, including DzMeshSmoothAction:
https://www.daz3d.com/forums/discussion/32354/script-to-carry-out-repetitive-actions
There is an amazing list of stuff there... some is pure gold :)
I know jack about DS scripting. What I'm looking for is a way to select an object and make one of my products have that object as its collision item. For example, I load a wearables preset that has two props in it. I want ONE of those props to collide with say, a Genesis 8 figure. So I select the Genesis 8 figure from the scene tab, then click the script button in the content library and it sets the collision item of the prop in question to be the Genesis 8 figure (or whatever figure I have selected).
I'm sure this must be possible. Can anyone point me in the right direction?
Thanks,
Causam
Hey everyone.
Here is a youube video that shows you how to do it.
https://www.youtube.com/watch?v=QILf-QJBhEY
Hope it helps.