Need some simple programming scripts for daz
![kmthrong_149911edc9](https://secure.gravatar.com/avatar/cc64b97cfa79782d1dc42cb394358896?&r=pg&s=100&d=https%3A%2F%2Fvanillicon.com%2Fcc64b97cfa79782d1dc42cb394358896_100.png)
Hi guys I usually use listeners for learning scripting like maya I learnt Mel using maya script editor which shows whatever that you do.why daz 3d doesn't have this feature it's so bad. :(
Couple of days just looking how to set a value to a blend shape in daz and how to set a key on it and go to the next frame in the time line these are the three simple things that I need any body knows what are the codes?tnx.
Comments
Have a look at the samples - in particular http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start covers gettign a list of properties. Also look at the scripting forum http://www.daz3d.com/forums/categories/daz-script-developer-discussion
Tnx but I didn't get anything don't know even were is the script editor is it Script IDE??
When I run something I don't get any result don't get anything from this.Would you plz tell me the codes cause I don't really need daz that much I use maya but now I just want to do these four things with it:
1-Set a value.
2-Set a key (I mean animation key)
3-go to the next frame
4-export a file to fbx.
Plz help me with this. tnx again.
Yes, ScriptIDE is the editor (and has a debugger).
The - as yet incomplete - docs for the DS 4 functions are at http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/start , though it is worth getting the DS 3 docs too as a lot of elements carry over http://docs.daz3d.com/doku.php/public/software/dazstudio/3/start
What you want are DzElement:findProperty ( name ) or DzElement.findPropertyByLabel ( label ) (where the DzEleemnt will usually be the bone or figure you are working on, or the object for a morph for a Morph - DzNode.getObject().findModifier( name ) then use getValueChannel() to get its property controller).
Once you have the property you have getNumKeys(), getKeyValue( n ), getValue( ) or getValue( time ), and various setValue() objects on DzProperty, .DzNumericProperty, and DZFloatProperty (each of which derives in turn from the former).
Ok tnx for the reply Richard.
But the point is I still get nothing I ran some of your codes but I get this same error What's wrong should I define a language programming first for this syntax error??:
And for this:
Sceen.getPrimarySelection()
I get:
Executing Script...
Script Error: Line 1
ReferenceError: Can't find variable: Sceen
Stack Trace: ()@:1
Error executing script on line: 1
Script executed in 0 secs 2 msecs.
Nothing really works wish I could MEL :(
Scene, not Sceen.
You need to get the primary selection (if that is what you want to work on), check it's a valid type (usually using .inherits( classname )), then use the findProperty on that, then set or examine the values on that (checking for validity each time).
(This is what Rob calls arrow code, but I haven't sorted out the anonymous function approach that prodcues neater results yet)
If you execute this in the ScriptIDE pane it will print its results under the edit panel, if you run it from a file it will print to the log.
Hi again tnx for the code it works and gives me the value of the Lats size.But how to set a value I tried:
But I get:
Script Error: Line 4
TypeError: Result of expression 'lats.setValueChannel' [undefined] is not a function.
Stack Trace: ()@:4
Didn't get this part BTW:
And before using this I think we need to set a key but how to Set the value of the controller choose the frame for example Go to frame 2 and then set a key.
Really tnx for your help :)
You need to get the ValueChannel for the modifier and use setValue on that. SetValue can take a time as well as a value, which is how you create a key (I think - it's not a feature I have used).
Tnx again but that's exactly the problem now how to set a value??And how to go to frame for example 2??
I tried:
lats.setValue(1);
lats.setValueChannel(1);
but it doesn't work.and I still don't know how to go to frame 2.
Plz help me more and tnx again for the replys dude.
You have the valueChannel, as an object so-named, from lats. lats is the modifier - the morph, its label and name, and the parameter that controls it; valueChannel is the actual controller and it's that that needs adjusting. Starting (ideally) from a figure without aniamtion this will add keys at frames 0, 15 and 30:
Note that the time is set in "ticks", one second is four-thousand-eight-hundred ticks. This is covered in the DS 3 scripting docs for DzTime.
Thank that's working pretty well :)
Also wrote a code in cmd for converting the number of frames to ticks.
Your script works with some morphs but doesn't work with some too which I don't know why.you know my question is.
If it's lats size for example how do you know the morph name is PBMLatsSize.What is PBM??
I tested :
var lats = object.findModifier( "PBMAA" );
But it doesn't work I figure maybe the name here is not:
PBMAA
I don't know maybe something else could you tell me where did you get it from I mean PBM??
Click the gear icon on the morph's slider and select Parameter Settings, the morph's name will be listed there.
Tnx for the information ok now I know the name:
eCTRLvAA
But still doesn't work maybe I noticed that your awesome script works with Modifier/Shape
But doesn't work with Modifier/Pose.
Would you plz help me on these last parts too tnx again you're a great dude!!!!!!!
If it's a pose modifier it will belong to the figure itself, so you can use findModifier on figure and skip the getting the object step (if you want only pose modifiers).
Tnx again buddy but it doesn work agian don't know why I edited:
var lats = figure.findModifier( "eCTRLvAA" );
and deleted the :
var object = figure.getObject();
But now it tells me:
TypeError: Result of expression 'figure.findModifier' [undefined] is not a function.
Sorry, you need findProperty( name ) not findModifier( name ). You could also use findPropertyByLabel( label ) which would avoid the need to get the morph's name.
Rob has updated the Node properties sample script to demonstrate both getting a full list of the properties on a node (showing the different handling of modifiers and others) and fidning a property by label or name: http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start Using code like that to retrieve the proeprties you can then apply the stuff in my example above to manipulate values and keys.
TNX a lot Richard Finally I achived the purpose here's the final code for selecting AA and adding keys on it :) :
Good, glad to have helped (or passed on Rob's help)