What is the proper way to load an expression on a character?

I'm really struggling to understand how to [load an expression on a character] do this. I can't really seem to find any good examples on how to do anything in DAZ Studio scripting.

I made this (fairly trivial) function:

function loadExpressionOnCharacter(characterLabel, expressionPath) {	var oNode = Scene.findNodeByLabel(characterLabel);	oNode.select(true);	var oResult = App.getContentMgr().openFile(expressionPath, true);	if (oResult.valueOf() !== true) {		throw "Error";	}}

It works. It loads the file and applies the expression to the character, but:

  • The biggest problem I have with this is that it also focusses the application. This is very strange to me. It's a bit difficult to pinpoint where the problem is exactly because it's not so easy to reproduce (I have to mimize the application manually and then see if it steals focus). This means that while my script is running I can't use the computer for anything else because DAZ Studio keeps coming to the foreground. If I explicitly minimize DAZ Studio, it doesn't come to the foreground, but it still steals focus.
  • Another issue is that this is very slow. I've got a script that's going through multiple of these and it's chugging.

I also tried `App.getAssetIOMgr().doLoad()`, and that function suffers from the same problem, on top of the "OpenNew" modifier not working, it just always merges.

I'm really hoping there is a better way to do this.

Is there perhaps a better way of running scripts? So far I'm either just executing my `.dsa` file directly, or going through the "Script IDE" and using the "Execute" function.

If anyone knows a good source of examples I'd love to hear it. The documentation on http://docs.daz3d.com is sadly not very good at all.

 

Post edited by Richard Haseltine on

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,948

    You could do with some error checking in there - for example, making sure that there was a return for the attempt to find the character. I'm not sure about the focus issue.

    You can't open an expression, since it is only a preset that needs a pre-existing, selected target. If you use a file that creates/loads content you should be able to merge or load it as desired.

Sign In or Register to comment.