Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all 1036 articles
Browse latest View live

DzQuat question

$
0
0

 

I have the following 2 scripts that find a node (merlins skull) and rotates it 90 degrees. the second uses an overloaded version of DzQuad

var nNode=Scene.findNode('MRLN_MSSkull_7542');

nNode.setLocalRot(DzQuat(0,1,0,Math.PI/2);

 

var nNode=Scene.findNode('MRLN_MSSkull_7542');

nNode.setLocalRot(DzQuat( DzVec3(0,1,0),(Math.PI/2)));

 

As you can see from the attached image, they give different results. 

image one is starting position, two is script 1 and three is script 2. (script 2 is how I would expect it to behave.) 

 


Blend an image stack in the Script GUI

$
0
0

I'm working on a script, and for a good user feedback, I thought I could use a stack of png images and blend them together, maybe using DLayeredImage, but it looks like those cannot be constructed from a script. Anyone have a good idea around that?

 

 

scaling an image within a pixmap

$
0
0

Hello everyone!

I'm trying to add in a dialog several pixmaps with images loaded somewhere else in the script. This is not fundamental, but this would be "much more cute" this way (gosh, it's always like this when women are scripting?!).

For now I have no issue to add the pixmap with the "big" image, my issue is the scale of the initial images. In general they are big images (>2000x2000) that I want to fit in a 200x200 pixmap (the pixmap supported by a DzLabel in the dialog : "wLabel.pixmap").

So far I tried :

- to use the Qt commands : scaledToWidth/ scaledToHeight but I failed

- the pixmap.resize(size), which crops the image, (well it does what it supposed to do : resize the pixmap, not the image)

- to load the file as an image "Image(sAbsolutePath)", rescale it, and place it directly in the pixmap, but this method does not seem to be supported (pixmap seems to need a path to be loaded). I tried the Qt function fromImage() to create the function from the image but once again I did not manage to use it.

- to load the file as an image "Image(sAbsolutePath)", rescale it, save it, and then the pixmap calls the image just saved. This could be the solution, my worry is being that I will have to save it, probably in a temp folder, and I don't know how to grab the temp folder of the user, and if I have to clean it or not at the end of the script.

Finally I decided to come here to ask the questions about what is the best way to rescale an image to place in a PixMap. Or maybe is there another solution, something else than the pixmap?

If there is no other solution, I guess I'm supposed to write temporary images in the "temp" file of the user, but is there a way to access the path of this file?

Thanks in advance for any help!

 

How to zoom viewport camera using script?

$
0
0

What's the best way to programmatically zoom in the viewport camera (equivalent to manual viewport controls)?

* Solved* Force a Iray Preview render to restart

$
0
0

My script change the contents of the file beloning to a file property (and the set the data to that file property), but if the filename is the same as last time, it doesn't trigger a refresh of the Iray preview scene, so the change is not visible. I've tired Scene.update() and Scene.invalidate() with no luck so far.

Anyone knows the trick to "kick the Iray preview in the rear" so it reprocesses the scene and starts to render with the new data?

Edit: The trick was to first set the filename to "", then back to the old one, then it triggered a change.

How to send Output ridisplay to window Preview render for Outline (DzScriptedRenderer)

$
0
0

Hello 

I have reviewed the files to generate the Outline effect, and works well with files
scripts \ support \ DAZ \ ScriptedRenderer \ Outline \ OutlineRenderScript.dsa that come with DAZ.
and help from here.
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/rendering/scripted_renderer_settings_save_preset/start

Renderer.riDisplay( "+" + sPathFile, sDisplay, sOutlineVar + ",alpha", aTokens, aParams );

But, how can I send the output(effect Outline)  to the "window render (preview)" ?, and not to a file.

Try with framebuffer, But it does not work

 

Renderer.riDisplay("+DAZ Studio", "framebuffer","outline1",aTokens,aParams);	

 

With the following code I was able to send data to the renderer window, but the image is corrupted.

Renderer.doDefaultDisplay();
Renderer.riDisplay("+DAZ Studio", "DAZ 3D/DAZStudio4 Public Build/displays/bitmap.dpy","outline1",aTokens,aParams);

 

More than two Environment maps

$
0
0

Hi, I was wondering if its possible to come up with a scrip, that lets someone, use more than two environment maps- in Render settings environment? It would be fantastic if you develeoped more entries...

Kind Regards

 

Get global position of Child vert

$
0
0

If I have a child object, oGeometry.getVertex() returns the local coordinates. Is there an easy way to return the global position instead? 


Setting Simulation Properties Under the Surfaces Tab Via Script

$
0
0

The following code is an old snippet that I've used in the past to set material properties. In this case, it never enters if( prop ), but works fine if I change "Dynamics Strength" to "Opacity Strength".

Anybody know if simulation properties under the surface tab need to be set a different way than normal material properties?

Thanks in advance if anybody knows.

- Greg

 

var nodes = Scene.getSelectedNodeList();
var n = nodes.length;

for( var i = 0; i < n; i++ )
{
    var obj = nodes[i].getObject();
    if( obj )
    {
        var nShapes = obj.getNumShapes();
        for( var j = 0; j < nShapes; j++ )
        {
            var shape = obj.getShape( j );
            var nMats = shape.getNumMaterials();
            for( k = 0; k < nMats; k++ )
            {
                var mat = shape.getMaterial( k );
                if (mat.getLabel()=="1")
                {
                    var prop = mat.findPropertyByLabel( "Dynamics Strength" );
                    if( prop )
                    {
                        prop.setValue( .99 );
                    }
                }
            }
        }
    }
}

Setting Align Options

$
0
0

How can you set the Align options through a script?  I know you can call the DzAlignAction to execute the align, but I need to set the options first.

Determining the actual class of an object

$
0
0

Hi,

How can I determine the actual class an object? For example: 

var oRoot = Scene.getSelectedNode(1).getSkeleton();
var numProps = oRoot.getNumProperties();

var oProp;
for(var i = 0; i &lt; numProps; ++i)
{
   oProp = oRoot.getProperty(i);

   // determine the class of current oProp
   ???
}

I've tried "typeof" and "oProp.__proto__" and all returns "Object". How can I determine which subclass of DzProperty oProp actually is?

Thanks

 

Creating new morph channels with script

$
0
0

Hi,

I've been playing around on an idea of creating new morph channels on the fly, much like Poser's PMD files do. Sadly the PMD plugin AFAIK died off as of DS 4. I think I'll give it a shot using a script.

As a test, I setup/modify Victoria 4 cr2 file to add a channel to accept one of NGM morph, and compare it to a plain Victoria 4 with the same channel created by script.

As far as my test go, it seems that when loaded to DS4.9, only the root object (DzSkeleton) has a DzObject. All other bodyparts doesn't have DzObject. All the morphs/magnets loaded (like Morph++) has a corresponding DzModifier contained in the root's DzObject. All of them has the name/label with "MorphChannelName_BodyPartName" format, i.e. "FBMVoluptuous_chest". In closer inspection, the DzModifiers will have 1 DzFloatProperty with the same name of the DzMorph, and path with "/Morphs/Imported/[BodyPartName]" format, i.e. "/Morphs/Imported/chest". Setting several of the default morphs property hidden flag to false will cause those morphs listed in V4's BODY part in the "Morphs/Imported" group. With the editor's parameters tab in edit mode, such morphs will have an "M" icon in front of it.

image

All those familiar morphs in the "Morphs | Shapes" group have a corresponding DzFloatProperty in their respected DzNode. However, with the parameters tab in edit mode those morphs will have a "P" icon in front of it.

image

Curiously, if I select a bodypart other than root, the icon in front of the morphs is "A" instead of "P".

image

Upon opening the parameter settings, I found that the "P" and "A" will refer to the "M" in the root. With that info, I wrote this script

// DAZ Studio version 4.9.1.30 filetype DAZ Script

var oRootNode  = Scene.getSelectedNode( 0 ).getSkeleton();
var oObject    = oRootNode.getObject();

// Create new morph
var oMorph = new DzMorph;
oMorph.setName( "NGM_0_chest" );
oMorph.setLabel( "NGM_0_chest" );

// Create new property to replace the one already exist
var oMorphProp = new DzFloatProperty( "NGM_0_chest", true, false);
oMorphProp.setLabel( "NGM_0_chest" );
oMorphProp.setPath( "/Morphs/Imported/chest" );

oMorph.insertProperty( 0, oMorphProp);

// Add modifier to root
oObject.addModifier( oMorph );

// Create new property for the root node
var oNewProp = new DzFloatProperty( "NGM_0", true, false);
oNewProp.setPath( "/Morphs | Shapes/NGM_V4" );

oObject.addProperty( oNewProp );

Running the script to a plain V4 will a new "M" parameter in "/Morphs/Imported/chest" as well as a "P" parameter in "Morphs | Shapes/NGM_V4". However, after injecting the morph data from the PZ2 file, the sliders of those 2 new parameters / morphs don't have effect. In contrast, if I use the cr2 where the corresponding channel already edited in, sliding "M" parameter do have effect / the morph works.

How can I fix this problem?

THX

Getting label of layered image

$
0
0

I can't seem to get the label of a layered image... .label returning undefined..

 

	oMap = oProperty.getMapValue();
	if( oMap ){
		if( oMap.className() == "DzLayeredTexture" ){
			NumOfLayers = oMap.getNumLayers();
			for( var i = 0; i &lt; NumOfLayers; i++){
				cLayer = oMap.getLayer(i);
				LayerLabel = cLayer.label;
				debug( String( %1 ).arg( LayerLabel ) );
			}
		}
	}

 

A question about 'Render DrawStyle' Sample error

$
0
0

Hi!
I am running the "Render DrawStyle" sample and it throws me an error in line 156.

// Set the alpha for the image to a color mask
oImage.setAlphaFromMask( oImage.getColorMask( clrMask, true, 10 ) );

Script Error: Line 156

TypeError: Result of expression 'oImage.getColorMask' [undefined] is not a function.

I checked the Image object in the API and it has no 'setAlphaFromMask' nor a "getColorMask" methods! Image inherits from Qobject but it has not that methods either!

Are they methods of Image Object, and where can I find them as they are not refered to the API?

Applying Poses, Camera, saving scene

$
0
0

This was something I did in Poser for my workflow using python.  Think of it as a mass rendering setup - and I'd like to see if I can do it in Daz.

Essentially fill a scene with a few characters, 1 or 2.. and run a script that applies a pose to each character, and sets a camera.  That scene is either saved or best case sent to a queue for rendering.   Then apply the next two poses and camera and so on.

I understand that while this script is running, the user can't use daz, but that would be fine - it would be something running overnight anyway.  I started looking through some of the documentation just now - but if it's not possible I'd like to save time.

With poser I was able to send the scene to the queue renderer and move right along to the next set of poses.  Not sure I can do that with Daz but I did see one 3rd party product for queue rendering daz scenes, so perhaps that would be what I need to do,  Although I'm not sure that product supports iray rendering.

Thanks for any help


Watchout for this little "trap" I tripped in

$
0
0

I was using the DzListView and DzListViewItems

I had an object that I stored with the list view items addDataItemString key, Object val )

It worked well, for a bit, but then when that was read back using Object : getDataItemString key ) later on in the code (by a click handler for the list), Poof - DS crashed.

After some logging and a change, I realized that the object stored with addDataItem will be purged by the garbage collector if it's not also stored into an array in the class.

The time before the crash was very random, from 20 seconds to minutes..

 

wordwrap for DzLabel is broken on 4.10

$
0
0

Hello,

I just saw by testing some of my new scripts on 4.10 that the command wordWrap does not work any longer.

Then I just checked some of my older products and I saw that they had the same wordWrap issue. On older versions of Daz Studio, the wordWrap works.

Is there a new procedure to have a label "wrapped in the box"? Is it known and planned to be solved?

In the meantime I'm gonna try to find alternate - but less elegant - solutions to finish my products without the wordWrap, but I'm interesting to know if the function is going to come back later on, or if I have to plan a general update for my older products.

Thanks!

How to read or set the Ambient Strength of a Material

$
0
0

This is where I got...but missing the way to read or set the value (like 0.1 or 10%)


if(!(node = Scene.getPrimarySelection())){
	 return;
};
print ("node= "+node.name);
shellObject = node.getObject();
print ("Object= "+shellObject.name);
shape = shellObject.getCurrentShape();
print ("Shape= "+shape.name);
var iMat = shape.getNumMaterials();
	for( j = 0; j &lt; iMat; j++){
		mMaterial = shape.getMaterial ( j);
		print ("Material= "+mMaterial.name);
		oProperty = mMaterial.findProperty( "Ambient Strength" );
		print ("Property= "+oProperty.name);
		oProperty.setValue = ( 0.12 );
		print("Value= " + oProperty.value);
	};

...but oProperty.value appears to be the wrong thing.  Tried name, getValue , as well...the last two lines to read or set the value don't seem to work.

What am I missing, or where in the docs am I missing it?  :)

What's the best way to learn Daz Scripting?

$
0
0

Ok, so from what I can gather, Daz Script 2 is an extension of QtScript, which is an extension of ECMAScript, which is a standardized form of JavaScript. So would I be better off learning JavaScript first, then moving to Daz Script? I ask because I'm a little bit old school (C=64 era) and I learn better when I have a book I can sit down and read. There are tons of books on JS, but I doubt I'd find any on DS. I'm familiar with programming (Basic, Cobol, Pascal) but the only modern language I've studied is Java.

Second, how similar is DS to JavaScript? Will learning JS first screw me up, or will it give me a solid foundation to learn DS more easily?

[Solved] Is there a way to change the image gamma using DzTextureModifier?

$
0
0

The "Image Editor" has the ability to read and edit image gamma, so logically, so should DzTextureModifier, except I can't find a method or property that allows me to do so. Has anybody figured out how to do this?

Viewing all 1036 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>