Is there a way to change the gamma value of texture by script?
Texture gamma
Daz Uber Iray Instance Tiling - How to Change?
I am trying to make a script that will change the instance tiling (in the Image Editor) for a bump map image in an Iray shader. In my duf file the only things I see referring to it's tiling are these 2 lines:
"url" : "name://@selection#materials:?extra/studio_material_channels/channels/Bump%20Strength/image_modification/horizontal_tiles",
"keys" : [ [ 0, 5 ] ]
"url" : "name://@selection#materials:?extra/studio_material_channels/channels/Bump%20Strength/image_modification/vertical_tiles",
"keys" : [ [ 0, 5 ] ]
I have looked a long time for a way to do this but I just don't understand Daz Script well enough. I can get to the Bump Strength value but that's as far as I could get.
Any help is really appreicaited.
Script Iray Draw Settings?
Hello--
Is it possible to change Iray Draw Settings via script (not to be confused with Render settings)? Or better yet, is there a way to create and apply an iray draw settings preset? For example, I would like to change Draw Settings->Drawing->Draw Mode from Photoreal to interactive via script
Thanks!
Error/Warning 'properties\dzenumproperty.cpp(734)'
I have a script loading some H.Materials and Materials files. My object (a book) has 2 Material Surfaces ('Cover' and 'Pages').
If I load an Iray Material (or H.Material) Preset, everything is fine:
Scene.setPrimarySelection(aMyBook.bookNode);
var oContentMgr = App.getContentMgr();
oContentMgr.openFile(localPath+"IrayCoverPresetFile.duf", true);
oContentMgr.openFile(localPath+"IrayPagesPresetFile.duf", true);
If I try to load a 3Delight Material (or H.Material) Preset:
Scene.setPrimarySelection(aMyBook.bookNode);
var oContentMgr = App.getContentMgr();
oContentMgr.openFile(localPath+"3DelightCoverPresetFile.duf", true);
oContentMgr.openFile(localPath+"3DelightPagesPresetFile.duf", true);
I get an Error/Warnig "properties\dzenumproperty.cpp(734): Index out of range in DzEnumProperty::getItem()" but the file is loaded correctly:
var bFileLoaded = oContentMgr.openFile(localPath+"3DelightPagesPresetFile.duf", true);
print("File loaded:" + bFileLoaded );
returns "true"!
I noticed that the second 'oContentMgr.openFile()' command throws the error/warnig, which reffers to the 2nd matterial surface (pages) of my object.
Does anyone has come across this problem and know any solution? Is it critical for the execution of the script, or can be overlooked?
Thanks in advance!
adjust property "Use Limits" in script [SOLVED]
Hi Everyone,
This is probably a really easy answer but I have been looking through the API and several pages trying to find out how to set a control property to not "use limits" I will in turn be writing another script that turns the limits back on and then sets each of the mins and maxes to a certain integer. I know I can easily go to figure and then click on enable limits but I would really like to include it in my script.
How can I change the Set Limits of a property to on or off using a script?
Here is what I have so far that is of course not working
var limit = nodes[n].findPropertyByLabel( "limits" );
if(limit){
print("found it");
limit.setValue(true);
}
Thanks in advance for any help.
Relative Paths
I feel like I'm missing something really obvious here, but I've got a script that works as long as I use absolute paths. It's pretty simple. I just call 2 different files to apply them both. Is there a way to use relative paths? I can't find any documentation on the relative paths or sample code using them.
var oContentMgr = App.getContentMgr();
oContentMgr.openFile("C:/Users/CC/Documents/Secondary Runtimes/Ciara/People/test1.duf", true);
oContentMgr.openFile("C:/Users/CC/Documents/Secondary Runtimes/Ciara/People/test2.duf", true);
Setting UVs on a material
I was wondering... is there a way to set UVs on a material by its name? Setting it by its index works:
var baseUV=myMaterial.findPropertyByLabel("UV Set")
baseUV.setValue(2);
But on different figures, the UV map matching such index may not be the same...
G3 to G8 script possible?
So the Autofit for G3f to G8f always fails under the arms for me...the mesh stretches to pieces, so I fall back to Sickleyields conversion
Is setting the preferred base, and transferring rigging to shape possible via the SDK? If so, if you can point me to the right spots in the doco, I may write up a script to save some time.
How to load a texture file into the base color shader of a node (Iray) (SOLVED)
I have one geometry which is splited into a great number of textured elements. Instead of loading one by one the textures of these elements, I write a little script which can do it automatically, based on a text description. I'm able to choose and retreive the node and/up to the material to work with but when I search the property of the material using the material.findProperty("Base Color"), it doesn't give any property.value and I'm not able to use the property.set value or Mat instruction.
Is there a simple way to load a texture file name into the "Base color" or any other property of that Iray shader?
How to Save a rendered image & Add Canvases
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.
Transfer Utility
I have constructed a test script. Said script pulls scene selected nodes as objects, let's call them object 1 and object 2.
So far, so good. Debug shows this part happens.
I then construct a transfer utility object using the default constructor. Call this oTransfer
Then a function, which takes as inputs object 1, object 2, and an array of morphs. Said fucntion uses the various set methods for DzTransferUtility on oTransfer. (say oTransfer.setFitToFigure( false );)
We then end with oTransfer.doTransfer()
The ScriptIDE says the script returns true for doTransfer. Nothing, however, happens. Debugging every part of the script is returning expected results so I assume I am not actually using DzTransferUtility as intended.
Am I supposed to be calling the TU action and passing it a settings object constructed using DzTransferUtility? I've been casting about the docs for a couple of days and I'm not seeing anything jump out at me. Not looking for a solution handed down as much as needing a pointer in the direction this is expected to go. I could be totally off base, but given that everything checks out, I'm assuming there's a step I'm not taking, or I am totally misusing the object/methods.
Get the path + filename of the current opened scene
Hi,
I can't find any clue about getting the path and the name of the current scene opened in Daz
Let say I opened c:\test\exemple.duf file in daz, how can I get this info using script ?
I've seen things with DzFIleInfo or DzFile but a path is needed
Thanks
Modular arithmetic
I would expect any operation mod n to return a value in [ 0 , n - 1 ]. Using the % operator in Daz Script that works for addition but not for subtraction:
for ( var i = 0 ; i < 4 ; i++ ) {
print ( ( i + 1 ) % 4 );
print ( ( i - 1 ) % 4 );
}
returns:
1
-1
2
0
3
1
0
2
instead of the expected (by me):
1
3
2
0
3
1
0
2
Which of us is wrong, Daz Script or me? And if it's the latter, is there a neater way to get my expected behaviour than testing for 0 in subtraction operations and giving it a special result of n - 1 instead of -1?
Scripting: Modifying Daz Script to prompt for file name?
I'm trying to use this daz script sample: The Save a Pose Preset
It saves without opening the dialog window...like the checkboxs and asking for the file name.
I would like it to promt for a file name, but continue to do everything else automaticaly. (currently, it over writes its previous use when used)
I've looked thru the code but I don't know the langauge...I'm experience with some scripting langauges, but not this...but from what I think I've figured is to do what I want will take a bit more coding than just changing a flag from false to true.
BUT, maybe I'm wrong, and there is flag I haven't id'd that will do it.
So, I'll ask the assembled brains here if this is an easy fix, or if it's something I'll need to table to after I've learned the language more.
Simple explanation for a C# developer (classes/inheritance)
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.
Silent Export without showing options AND without showing File Dialog
I have been playing around with the publicly available "Export Selected Object" script.
I use this script in order to export an obj that I later load into blender.
I need to do this for about 3 to 4 things and really just want to hit the button in DAZ that will eport it as my !!ToBlender filename without asking me via a filedialog. I know its super lazy to not hit enter and then YES but I figured this has to be possible. What do I need to change in the FileDialog part in order to get my obj with the settings below to just WriteFile without the file dialog?
I have pasted my current script below.
// DAZ Studio version 4.9.4.117 filetype DAZ Script
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){
// Get the primary selection to use for the file name
var oNode = Scene.getPrimarySelection();
// If something is selected
if( oNode ){
// Get the node's skeleton
var oSkeleton = oNode.getSkeleton();
// If it has a skeleton
if( oSkeleton ) {
// That is the node we want for the name
oNode = oSkeleton;
}
}
// Get the export manager
var oExportMgr = App.getExportMgr();
// Define the class name the for Wavefront Object (*.obj) exporter
var sClassName = "DzObjExporter";
// Find the exporter
var oExporter = oExportMgr.findExporterByClassName( sClassName );
// If the exporter exists
if( oExporter ){
// Create a settings object
var oSettings = new DzFileIOSettings();
// Fill the settings object with the default options from the exporter
//oExporter.getDefaultOptions( oSettings );
// Define whether or not to show options
var bShowOptions = false;
// Define whether or not to show options before prompting for a path;
// requires 4.9.3.22 or later
var bOptionsBeforeFile = (bShowOptions && App.version64 >= 0x0004000900030016);
// Get the options for the exporter
if( !oExporter.getOptions( oSettings, bShowOptions && bOptionsBeforeFile, "" ) ){
// We're done...
return;
}
// Debug
//print( oSettings.toJsonString() );
// Set the desired settings for the exporter
//oSettings.setStringValue( "Preset", "Poser (1 unit = 8ft)" );
// Set the scale to write the data
oSettings.setFloatValue( "Scale", 243.84 );
// Set the lateral axis to X
oSettings.setStringValue( "LatAxis", "X" );
// Set the vertical axis to Y
oSettings.setStringValue( "VertAxis", "Y" );
// Set the depth axis to Z
oSettings.setStringValue( "DepthAxis", "Z" );
// Do not invert the lateral axis
oSettings.setBoolValue( "InvertLat", false );
// Do not invert the vertical axis
oSettings.setBoolValue( "InvertVert", false );
// Do not invert the depth axis
oSettings.setBoolValue( "InvertDepth", false );
// Do not ignore the geometry of invisible nodes
oSettings.setBoolValue( "IgnoreInvisible", false );
// Do not weld seams between parent and child bones on legacy figures - deprecated
oSettings.setBoolValue( "WeldSeams", false );
// Do not remove vertices that are floating, connected to nothing - i.e. LOD
oSettings.setBoolValue( "RemoveUnusedVerts", false );
// Write vertex textures - UVs
oSettings.setBoolValue( "WriteVT", true );
// Do not write vertex normals
oSettings.setBoolValue( "WriteVN", false );
// Do not write object statements for each root node - i.e. figures, props
oSettings.setBoolValue( "WriteO", false );
// Write facet groups
oSettings.setBoolValue( "WriteG", true );
// Write facet groups according to whatever the geometry already has
oSettings.setBoolValue( "GroupGeom", true );
// Do not write facet groups according to the node it is associated with
oSettings.setBoolValue( "GroupNodes", false );
// Do not write facet groups according to surface groups
oSettings.setBoolValue( "GroupSurfaces", false );
// Do not write one facet group
oSettings.setBoolValue( "GroupSingle", false );
// Write surface groups
oSettings.setBoolValue( "WriteUsemtl", true );
// Do not write a material library
oSettings.setBoolValue( "WriteMtllib", false );
// Do not collect texture maps
oSettings.setBoolValue( "CollectMaps", false );
// Do not convert texture maps
oSettings.setBoolValue( "ConvertMaps", false );
// If the version is 4.5.0.114 or newer
if( App.version64 >= 0x0004000500000072 ){
// Do not limit export to selection
oSettings.setBoolValue( "SelectedOnly", true );
// Do not limit export to the selected roots
oSettings.setBoolValue( "SelectedRootsOnly", true );
// Do not limit export to the primary selected root;
// this setting overrides SelectedRootsOnly
oSettings.setBoolValue( "PrimaryRootOnly", false );
// Do not export items that are parented to the selection
oSettings.setBoolValue( "IncludeParented", false );
// Do not triangulate n-gons
oSettings.setBoolValue( "TriangulateNgons", false );
}
// If the version is 4.9.3.22 or newer
if( App.version64 >= 0x0004000900030016 ){
// Do not collapse UVs Tiles
oSettings.setBoolValue( "CollapseUVTiles", false );
// Show individual settings in the dialog
oSettings.setBoolValue( "ShowIndividualSettings", false );
}
// Define whether or not to show the options after prompting for a file
oSettings.setIntValue( "RunSilent", (bShowOptions && !bOptionsBeforeFile ? 0 : 1) );
// Debug
//print( oSettings.toJsonString() );
// If we've got a node, construct the path using the
// exporter's last path, the node's name, and the
// exporter's extension...
// Otherwise, just use the exporter's last path
var sInitialPath = ( oNode ?
String( "%1/%2.%3" )
.arg( oExportMgr.getExportPath() )
.arg( oNode.name )
.arg( oExporter.getExtension() ) :
oExportMgr.getExportPath() );
// Prompt the user to choose a file,
// use the exporter to build the title bar caption,
// the initial path and the filter
var sPath = FileDialog.doFileDialog( false,
String( "Custom Export : %1 : %2" )
.arg( oExporter.getDescription() )
.arg( oSettings.getStringValue( "Preset" ) ),
"M:/M_Daz/Blender/!!toBlender",
String( "%1 (*.%2)" )
.arg( oExporter.getDescription() )
.arg( oExporter.getExtension() ) );
// If the user didn't cancel and the file doesn't already
// exist, or the user wants to overwrite it
if( sPath && MainWindow.checkExistingFile( sPath ) ){
// Write the file using the options specified
oExporter.writeFile( sPath, oSettings );
}
// Clean up; don't leak memory
oExporter.deleteLater();
// We didn't find an exporter with the class name we wanted
} else {
// Inform the user
MessageBox.critical( qsTr("An exporter with the class name \"%1\" " +
"could not be found.").arg( sClassName ),
qsTr("Critical Error"), qsTr("&OK") );
}
// Finalize the function and invoke
})();
Thanks so much
Writing a little script to open a PDF file?
Hey guys,
I am looking for a little script that will open up a PDF user-guide when clicked on. The purpose is simple: Rather than having the user search the support folder for my PDF manuals, I would like to include a "link" to them directly in my product folders. I saw some other PA's have done this with their products, but I do not quite understand the code for the script.
Any help in this regard would be appreciated,
-P
Script to auto select left eye for focusing camera
Hi
I'm trying to write a script to auto select the left eye, once selected i would the run a second script to focus the camera on the left eye. The second part of the script is done, i managed to modify the script created by By cwichura
"Set focus distance", it originally worked by finding the focal distance of a null object. I modified it so now it will find and set the focal distance of any object selected, example left hand, right eye, foot, etc.... You have to select the body part, then run the script and it works.... I've been using it for a month or so.
As a photographer who takes portraits for a living, 99% of all my portraits will focus on the closest eye to the camera, left eye or the right eye. I do not except the script to figure out which is the closest eye to the camera, (though that would be nice)
What I would like to do is have 2 scripts, that i can run once a figure is selected.
1) focus camera left eye
2) focus camera right eye
what i've been trying to do is to modify the focus camera script, this line in particular
var oTargetNode = Scene.getPrimarySelection()
instead of Scene.getPrimarySelection() i'd like it to always select the left eye of the currently selected figure. (I’ll have a second script for the right eye)
thanks,
ctor for DzMenu
Does anybody know, who to show a context-menu when right-clicking (i.e. a DzListViewItem).
Following code does not work:
var menu = new DzMenu();
menu.addItem("Clear Poses");
menu.addItem("Clear Shapes");
menu.exec();
results in:
Script Error: Line 276
TypeError: no constructor for DzMenu
Stack Trace: ()@X:/.../Library/Properties/UI/CQuickFigureDialog.dsa:276
Is there a constructor for DzMenu?
to close the dialog after pause
Hi!
I can't understand how to close the dialog after pause automatically without pressing the buttons.
The task is simple, but... :)