Hello
While looking through several of the samples, I came across code that included references to an App class. I found the documentation for DzApp but not for the App class. Can anyone help me?
Hello
While looking through several of the samples, I came across code that included references to an App class. I found the documentation for DzApp but not for the App class. Can anyone help me?
Hello, I have just started with Daz scripting. I'm trying to load a file, add a canvas and save the rendered image as a png. I have been able to load a file, start the render and activate the canvases but I can't find out how to add an Emission or Glossy canvases. I have been able to render an image but I can't activate the render to file. Here is the current code:
var TempFile = "Z:/01Test.duf";
var oContentMgr = App.getContentMgr();
oContentMgr.openFile(TempFile, false);
print("scene Loaded");
var TempRenderer = App.getRenderMgr();
var TempRenderOptions = TempRenderer.getRenderOptions();
TempRenderOptions.renderImgFilename = "Z:/01TestSave.png";
TempRenderOptions.renderImgTarget = 2; // Direct to file (doesn't work)
TempRenderOptions.applyChanges();
//TempRenderOptions.renderImgTold = 2; // Tried this but also doesn't seem to work
print(TempRenderOptions.renderImgFilename);
if (!TempRenderer.doRender(TempRenderOptions))
{
MessageBox.critical("Render Canceled. ","Render","&OK","");
}
else
{
//TempRenderer.saveLastRender(); // Manual save
}
var TempData = App.getRenderMgr().getRenderElementObjects();
if(TempData[1].name == "NVIDIA Iray Render Options")
{
if(TempData[1].getProperty(3).name == "Max Time")
{
var TempProperty = TempData[1].getProperty(3); // Max Time
TempProperty.setValue(200);
print("Max Time:"+TempProperty.getValue());
TempData[1].renderToCanvases = true;
// I have manually added a canvas for testing how to add one and this gives me it's name but I can't add one by script
print("Canvas:"+TempData[1].getCanvasDefinition(0).name);
//TempData[1].clearCanvasDefitions();
}
else
{
MessageBox.critical("Property 'Max Time' not found.","Render","&OK","");
}
}
else
{
MessageBox.critical("Could not find 'NVIDIA Iray Render Options'.","Render","&OK","");
}
print("Script Ended.");
This thread has helped a lot but I'm missing information on how to add a canvas: https://www.daz3d.com/forums/discussion/196346/how-to-access-advanced-section-in-iray-render-settings
Thanks.
Me again, sorry. I've got a set of dynamically-generated buttons named switch0, switch1, etc. If I use findChildOfWidget("switch"), nothing is returned. If I try to use a wildcard (i.e. findChildOfWidget("switch*")), nothing is returned. If I separate the wildcard from the string (findChildOfWidget("switch" + *)), I get an error. Do wildcards even work in QTScripts? If so, HOW?
Here's the code I have:
function hasfad() {
for (i=0; i<swtch.length; i++) {
var fad = opt.indexOf(Scene.getNode(switches[i]).name);
if (swtch[i].down && fad == 0) {
loint.enabled = true;
hiint.enabled = true;
}
else {
loint.enabled = false;
hiint.enabled = false;
}
}
}
The script starts with an array of names for valid selections (I'm designing this script to work only with products I have designed for this purpose), and then a set of radio buttons within a button group, corresponding to the products in the scene that have the valid names. All that works fine. The problem when I'm testing this script is that fad = 0 for the first and fourth buttons, but the script only enables the two properties when the fourth button is pressed, not the first one. I'm having trouble grasping the logic behind that. If I PRINT fad within the if condition, it prints for both buttons 1 and 4, but not for buttons 2 and 3, so clearly the conditions are being met.
Also, is there a smarter way to indicate which button is selected? I haven't been able to get anywhere with the [buttongroup].checkedButton, and there's no documentation for it. If I print it, I get:
function checkedButton() {
[native code]
}
Every other operation parameter (name, index, etc.) is undefined. Does anyone know how this method works? I've also looked into putting the switch name/id/whatever into the function call, but I can't seem to get a handle on how that actually works.
I really hate asking so many questions, but...well, you've seen the documentation.
I am working on a script to change the Daz skeleton to match that of the Unreal Engine mannequin.
It's a request I have seen around the Daz forums and a personal scripting challenge I set for myself.
Even if the results aren't perfect its a goal and a project to learn more about Daz Studio scripting.
I have the bones I need renamed, relabeled, or removed. When bones are removed Daz Studio automatically reparents the remaining bones just fine.
What I'm stuck on is that in the Unreal Engine mannequin rig both the Shoulder Twist bone and the Forearm Bend bone are parented to the Shoulder Bend bone.
So I am trying to find a way to script reparenting the Forearm Bend to the Shoulder Bend bone
I have the script selecting the bone I need reparented, and using the triggerAction (DzJEReparentBoneAction) I do get the "Select an Item" pop up menu.
I am not sure how to script selecting a bone in that menu or how to "hit" Accept.
Maybe there is a easier way?
Below are the results with the script so far:
Hello there..
Absolute beginning here. I was wondering how to make a script for some functions from the daz menu.
for example if I select a genesis 8 female character, and pose it, then save it's pose into a specific folder as a posepreset, can the "saving the selected as a posepreset" part be made into a script? If so what would it look like? I know this sounds stupid.. sorry.. ^^
Plus I am looking for mentorship on daz scripting and will compensate for your time... let me know if any of you daz scripting gurus are interested freenomon@gmail.com
Kenneth
Hello there. Complete newbie here.. :)
After importing an fbx file with some rotation data, I want to retarget that rotation data to a joint of a character (ex: his index finger). How would I make a script for that fuction?
Thanks.
KC
The subject pretty much says it all - I need to obtain the (invisible) point in 3D space that the camera is currently orbiting.
Hello All,
According to the documentation, DzApp.getTempFilename() should clear up any files in the temp_dirs it creates when Daz shuts down. Unfortunately, this doesn't seem to be the case. I've worked around this by keeping track of the temp dirs that are created in my script and then before my script ends, I clear them up with the following code:
for(var i = 0; i < app_temp_dirs.length; i++) { // remove files in dirs var dir_to_nuke = DzDir(app_temp_dirs[i]); var files = dir_to_nuke.getFilesFromDir(["*.*"], true); for(var f = 0; f < files.length; f++) { dir_to_nuke.remove(files[f]) } // remove dirs dir_to_nuke.rmpath(app_temp_dirs[i]); }
The files get removed perfectly. However, any call to DzDir.rmpath(path_to_remove) that I try fails. Which means I'm left with a ton of empty dir structures.
I have tried relative paths, absolute paths, I've used DzDir.cdUp() to maybe get out of the way. etc. etc. etc. But I can't get it to work.
Would some kind soul put me out of my misery and tell me how it's done?
Hello everyone,
I have a project I'm doing which I hope to get onto the store at some point. At the moment i'm struggling through some image processing/manipulation where i'm iterating over every pixel in an image (Image.setPixel(x,y,color)).
For small images it can finish relatively quickly like in about 30 seconds to 1 min. But as the image size gets larger I've had it take as long as 10-15 minutes. And this is on my Ryzen 3900X with 64gb of ram. I still have more code to add in to polish it out which may raise this by a factor of 4 and maybe even 16.
All this has me thinking I need to offload this part of the process and have it be done in C++ as either a plugin or maybe a dll? And then hopefully that plugin or dll can be called from my existing Daz Scripts passing in the needed params?
I am not a C++ coder and never done anything with DLLs - which is why I started doing this project in Daz Script in the first place.But if there's no way to increase the processing speed, then I may be forced to anyway.
Assuming for arguments sake there is a way to do this, would I use DzProcess() to make the call to that plugin/dll, or is there another way I haven't seen yet?
Thanks for any light anyone can shed on this.
Is there any way to apply a figure's subdivision synchronously? Whenever a pose is changed the figure's base geometry updates synchronously, but if subdivision is enabled it doesn't get applied until some indeterminate later time. I need to drive a series of renders in subd resolution renders, and I'm finding that the renders only capture the base mesh resolution due to this issue.
I've tried calling DzObject.finalize(), but it causes the script to never return. DzObject.forceCacheUpdate() only produces the base geometry.
Thanks
Hi!
I'm trying to change the UV Set of a script generated shell either per script or when I apply the material. I can't get it work. I've loaded in the UVSet on the base figure and saved it as a UV Asset. I can change the UV Set manually in the base figure and in the generated shell - so this works fine. But somehow it's not possible to change this property via script. And it seems like it's also not saved in the material preset.
Here is the part of my script (I can succesfully change other values of the material):
Scene.findNodeByLabel("MyShell").select(true);
var node = Scene.getPrimarySelection();
var nodeShape = node.getObject().getCurrentShape();
var numMats = nodeShape.getNumMaterials();
///////////////change uv set
for (var mats = 0; mats < numMats; mats++)
{
var curMat = nodeShape.getMaterial(mats);
var UVSet= curMat.findProperty("UV Set");
UVSet.setValue("MyUV");
}
I hope someone can help me.
Thank you very much!
I am trying to automate the process of face transfer.
The idea is to pass the file path and gender type to a function. The function will then use the image and generate the model.
My initial approach was to use the DzFaceTransferSelectImageAction. But this prompts the browse to locate image dialogue, which beats the whole purpose of automation.
In order to bypass, I need to either get the function that is invoked by the Action (which I don't know due to the lack of documentation). The second option is to reference the combo box widget, and populate it with the file path without ever interacting with the locate image dialogue. The rest of the steps are easy.
Here is the code:
oPaneMgr = MainWindow.getPaneMgr()
actionMgr = MainWindow.getActoinMgr()
// Reference the pane
oFTPane = oPaneMgr.findPane("DzFaceTransferPane")
// Reference the options menu
options = oFTPane.getOptionsMenu().getItemList()
// Trigger the select image
// This is the part I want to change since it prompts the select image dialogue
actionMgr.findAction("DzFaceTransferSelectImageAction").trigger()
// Generate model (I will add a conditional whether the passed parameter for gender is male or female)
actionMgr.findAction("DzFaceTransferGenerateMaleAction").trigger()
I have tried to get the reference to the combo box using this method
var CMB = oFTPane.findChild("FaceTransferSourceImageCmb")
However, this doesn't work. It results in the following error:
TypeError: Result of expression oFTPane.findChild [undefined] is not a function
I am not sure why. It seems that the findChild() method is not included in the DzPane, even though it inherits from the QObject class which does have this method.
I have looked up Rob's examples for making a silenced importer/exporter and they will come very handy at a later stage. But, I can't apply them here. To change the image dialogue settings, I need to call the function directly, not the action itself.
So, to summaerize:
- Is there a way for me to locate an existing widget on a pane?
- Is there a way to get the function names the are executed by an Action? CallBack methods?
- Is there a different way to achieve the desired effect (silencing the image dialogue and passing a file path)?
Any help is much appreciated. Thanks in advance.
I've started playing with scripts. What I want to do is rotate an object - that bit I've got working (i.e. writing different Xrot values to successive frames). But it rotates about the bottom of the object, rather than its centre - so I've got to apply deltas to the Y and Z transforms to correct the apparant centre of rotation - and for that I need to use sin() and cos(). Except I get a runtime error "ReferenceError: Can't find variable: sin". So I assume I haven't understood the syntax correctly. I have the angle in radians in a DzVec3 variable (x, y, z) called ang (ang.x is limited to +/- PI), and the line which throws the error is as follows:
var deltaY = -(217 * sin(ang.x));
(217 being the distance from the base of the object being rotated to my required centre of rotation).
Hi all, this is probably the closest place for me to ask this question-
I understand that PostgreSQL is the DB being used in DAZ. I write SQL/DML queries in products like Oracle and MySQL relational databases but have never touched PostgreSQL in any of my job sites at my day gig. Is there a way for me to get to the actual tables in DAZ's postgresql database so that I can edit data across thousands of products that exist in my catalog without using the metadata editor? I imagine if I can find the relational database manager for postgresql and connect it to DAZ's DB tables it will be possible to do with UPDATE queries and the like. As far as I know, we as users can only Update/Create/Delete one product set of records at a time in DAZ Studios metadata editor in the Content Library. For editing data across multiple products, this is very tedious and cumbersome...
If there IS a way to do this via some sort of external RDBMS for PostgreSQL that would be AWESOMEEEE
Thanks for any suggestions!
Hi, everyone.
what is the different between getGeometry() and getCachedGeom()?
var oMale = Scene.findNodeByLabel("Genesis 8 Female");
var oObject = oMale.getObject();
var oShape = oObject.getCurrentShape();
var oGeometry = oShape.getGeometry();
print(oGeometry.getNumVertices());
var oVertexMesh = oObject.getCachedGeom();
print(oVertexMesh.getNumVertices());
result: 16556
65806
why get different numVertices?
Hello all,
I started looking into scripted rendering for 3Delight and I see in the Daz Scripting Documentation for the DzScriptedRenderer is says "Implements a scriptable RenderMan interface for the scene to render itself through the 3Delight renderer."
And then for the methods referenced points to a RenderMan 20 doc at (example for RiOption()): https://renderman.pixar.com/resources/RenderMan_20/options.html#rioption
What I don't see is what version of 3Delight does Daz use and does that version support all the features in the RenderMan 20 docs?
thanks
Hi @all,
For some purposes, I want to use (quite simple) inhertance in scripts an I saw this is possible, but a bit frustrating for me, because I can't find a complete reference for scripting. I 'm professional developer, but comes from the Windows C# world. Understanding Java-Script (or similar dialect) is surley not the problem. But where can I find a documentation of keywords (and so on) which are useable in DAZ-Script ??
The following example snippet should show, where I have problems:
CBase.superclass = Object;
CDerived.superclass = CBase;
///////////////
// CBase
//ctor
function CBase()
{
this.valueA = 10;
}
CBase.prototype.dump = ?virtual? function() //...how to declare as virtual?
{
print(this.valueA);
}
///////////////
// CDerived
//ctor
function CDerived() : base() //...how to call the base-ctor?
{
this.valueB = 5;
}
CDerived.prototype.multiply = function()
{
return this.valueB * ???.valueA; //...how to access properties from base?
}
//overwritten dump():
CDerived.prototype.dump = function()
{
base.dump(); //...how to call the base-function?
print(this.valueB);
}
Thx in advance for answering
Greets Peter.
Hi there,
I have a script that instantiate a new camera , position it and sets up the focal length and frameWidth( see exmple below)
cam.focalLength=20.78461;
cam.frameWidth=24;
The focalLength works fine, but the frameWidth isn't getting set.... after digging more into the docs I see that frameWidth is a read only attribute which explains why I can't set it. However, I assume there is another way around it just can't find any function that can do that.
Hopefully someone here knows the answer to that.
Thank you.
I've been using 'Not A Number' pose presets for a long time now (to move pieces in modular sets). They applythe trans/rot value ad infinitum, so it's not a fixed value - it just keeps adding the same value to the existing one. The ones I have are .dsa files (DS3.1) and although they still work perfectly well, I want to have them conform properly to 4.9 standards. Does anyone know how I would go about it?
Here are 2 samples - a 3.1 script and a 4.9 (a normal fixed value pose preset)
// DAZ Studio version 3.1 filetype DAZ Script
var xPos = 170;
var yPos = NaN;
var zPos = NaN;
function moveObject( object )
{
if( object == undefined )
return;
if( !isNaN( xPos ) )
object.getXPosControl().setValue( object.getXPosControl().getValue() + xPos );
if( !isNaN( yPos ) )
object.getYPosControl().setValue( object.getYPosControl().getValue() + yPos );
if( !isNaN( zPos ) )
object.getZPosControl().setValue( object.getZPosControl().getValue() + zPos );
}
beginUndo();
for( var i = 0; i < Scene.getNumSelectedNodes(); i++ )
moveObject( Scene.getSelectedNode( i ) );
acceptUndo( "Move selected object(s)" );
{
"file_version" : "0.6.0.0",
"asset_info" : {
"id" : "/Props/Maclean/Interiors/Corridors/Corridors%20Iray/Pose%20Presets/150.duf",
"type" : "preset_pose",
"contributor" : {
"author" : "maclean",
"email" : "",
"website" : "http://www.daz3d.com/maclean"
},
"revision" : "1.0",
"modified" : "2020-09-07T20:14:32Z"
},
"scene" : {
"animations" : [
{
"url" : "name://@selection:?translation/x/value",
"keys" : [ [ 0, -150 ] ]
}
]
}
}
TIA
mac
Edit - Can't get 2nd code snippet to Word Wrap - No idea why