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

Slice of Array of Objects

$
0
0

Trying to rearrange the selected nodes in a scene and group them by the number tagged at the end of the label. Also trying to do this without having to loop thru those selected nodes too many times. So I build a sparce array:

var aSelectedNodes = new Array(nSelectedNodes);

With my current test data that wil set it to 30 items, but the loop will only fill it with six objects that have four nodes each. 

While trying to get rid of most of the empty array I don't need, I did this, sliced out the non-empty items in the array:

  var aGroups = aSelectedNodes.slice(0,nTrueLength);

  print("aGroups.length ["+aGroups.length+"]");

I got a length back, so a thing happened, if not quite what I want. Because the objects inside the array don't seem entirely defined anymore; I get an error trying to access one of the objects inside the array.

Script Error: Line 149

TypeError: Result of expression 'aGroups[ndx]' [undefined] is not an object.
Stack Trace: ()@D:/OneDrive/3D Content/MyDazNav/Scripts/Gollor/Expand Adamasen Level.dsa:149
149: aGroups[ndx].oFrontzone.oOldPos = aGroups[ndx].oFrontzone.oNode.getWSPos();

If I understand the error it's saying that either the object inside the array item got borked, or one of the subobjects of that object got borked. 

So I'm wondering what should I expect the slice function to do when it's working with an array of objects of objects of objects?

 


Loading Scene Subsets and Presets via DS

$
0
0

I need to find out how to load Scene Subset and Preset files, such as Camera, Lights, Materials, and Shapes.

I've spent two days examining the API but haven't been successful. Any help will be appreciated.

 

Creating and deleting keyframes

$
0
0

 After selecting a figure or prop, I need to move to a specified frame, load a preset, and create a keyframe.

Any help willl be greatly appreciated.

 

A most Basic Question. How to Print a variable [Solved]

$
0
0

I'm trying to learn daz scripting, I've worked with JS before, though it's been awhile. Seeing the results of variable along the way has always helped me understand whats going on. I have used a lot of the examples and broke them down, but a problem I run into is when I do something as as simple as:

var node = null;

node = Scene.getPrimarySelection()

print (node);

The printed result is :

[object Object]

rather than Genisis8Female, or whatever I have selected. I know its got a value, because I can manipulate it with If statements correctly.

Anyone have any idea if this is normal behavior or what I've done wrong?

Using the include() statement

$
0
0

In the script I'm working on, I use the include statement at the top of the script to load a dsa, file which is similar to loading a DLL in C++. It works fine, and I can call functions within it from the main script.

In addition, I would like to dynamically include scripts that are listed in a text file. The reason for this is to support extensions which I might want to create down the road, and offer my users the extended functionality.

I've attempted to do this, but when I iterate through the file collection, the include statement fails. Example: include( sNextModule );

Anyone have a clue as to how this could work?

Creating Custom Classes

$
0
0

I'm sure there must be a way of creating custom classes, but I can't find an example anywhere. Let me show you what I need to do in order to get started.

The code below should construct two custom classes. The second is derived from the first.


// psudo code for a class constructor
class C_foo() : someDerived object
{
	var nVersion = 1.234;

	fuction getVersion()
	{
		return nVersion;
	}
}
// psudo code for a class constructor
class C_fooBar() : C_foo // derived from C_foo
{
	var sAuthor = "John Wayne";

	fuction getAuthor()
	{
		return sAuthor;
	}
}

I need to learn the correct syntax for creating class objects, and what they need to derive from.

Any help will be tremendously appreciated.

 

Script to Reset a Dial?

$
0
0

I was wondering if anyone knows what script command(s) will do the same thing as resetting a dial?  When I say 'reset' - it's the same as ALT-clicking on a dial, or clicking the little cog symbol and then clicking 'Reset' from the drop-down menu.  I don't think it's as simple as just setting the default value of the property, or zeroing the property, because the property might be controlled by another property.

item changing script needs to work on all characters in a scene

$
0
0

my script is to show and hide items that G8F is wearing, it only works on the original g8 in the scene when the script was created-i need it to be able to show and hide items on any g8 in the scene, for example, there could be 4 g8F in the scene-the best scenario would be it can work from one script but if that is not doable to have a separate script for each g8F would also be great, 

 

can someone give me a starting point how either one of these options can be achieved

thank you


Suppressing Movie Codec Dialog from displaying

$
0
0

Hi folks. I'm developing a batch render script as a means of learing DS scripting. The script can render multiple camera shots from multiple scenes, and everything is working with one problem. Presently, I'm only rendering movie files.

When it's about to render the next shot, the dialog pops up requesting you to select a codec. The dialog box is actually named 'Compressor', which is technically correct. It sort of defeats the whole purpose of a batch rendering operation when the user has to sit there and click the OK button each time.

I would have expected that DzRenderOptions would have provided the means, but apparently it doesn't. If anyone can show me how to do this I will be one happy cook!

 

What do I need to do to start developing Daz Studio Scripts?

$
0
0

What do I need to do to start developing Daz Studio Scripts?

I used to take classes in programming but it has been a while.  I was wondering which programming language does DS use for their scripts?  I know that Poser uses Python but what does DS use?  What else do I need to start up with scripts for DS?

Changing Render Type in Render Settings

$
0
0

It seems like it should be possible to change the 'Render Type' selection to  'Image Series' or 'Movie', but I have yet to figure it out.

Using DzRenderOptions, I can change some of the values in the Render Settings panel, but not the Render Type. 

I'm beginning to suspect that I need to use other classes, such as DzPane or some other interface. Can anyone help me out?

 

 

Creating dependencies between settings on the Surfaces tab and Parameters tab

$
0
0

(This thread is a continuation of the "follow-on stuff" that was going on in the DS: Creating a slider on the Parameters tab that can ONLY have integer values (+follow-on stuff...) thread over on the Technical Help forum)

I've now created very simple test script to apply bidirectional linking of parameters on the Surfaces tab to parmeters on the Parameters tab.

The script was cobbled together from bits of the post_load_material_proxy_create.dsa and post_load_material_proxy_link_properties.dsa sample scripts and the DzSettings documentation, replacing the ephemeral 'DataItem' with good old hard-coded stuff.

I left the script using the bidirectional DzNumericProperty::linkTo() to set up the links because I couldn't work out how to create a unidirectional DzERCLink (the DzERCLink constructors creating 'controllers' is one level of Object Obfuscation beyond me at present!)

 

The main problem I'd come up against over on the other thread was that applying a material preset sometimes (i.e. under certain criteria) breaks these links.
What I'm trying to do is find a way to maintain (or reinstate) these links when (after) a material preset has been applied.
Use of the DzCallBack was proposed as a solution, but I really can't get my head around that stuff.

So that's the introduction to what this thread is about.

 

Here's the script in-line if you don't want to download it but could do with a laugh!

    // This is just a simple test script to apply BIdirectional linking of parameters

    // HOW TO USE:
    // - Open DS4.8+,
    // - Create a primitive sphere
    // - apply a texture to the Diffuse Color (one that make changes to tiling offsets obvious)
    // - create two new float parameters on the parameters tab (in a new group/path called 'TEST',or anything you want) - names are "Vertical Offset" and "Horizontal Offset"
    // - run this script
    // The tiling offsets on the Surfaces tab are now BIdirectionally linked to the twonewsliders on the parameters tab
    
    MessageBox.information("STARTED...","INFO","OK");
    var sSettings = [
        '<Settings>',
        ' <Setting Type="Float" Key="Horizontal Offset">0</Setting>',
        ' <Setting Type="Float" Key="Vertical Offset">0</Setting>',
        '</Settings>'
    ].join( "\n" );

    var aNodes = Scene.getSelectedNodeList();
    if ( aNodes.length == 1 ){
        var oNode = aNodes[0];
        var sName = "Default"   // The material we're going to work with
        if( oNode ){
            var oObject = oNode.getObject();
            if( oObject ){
                var oShape = oObject.getCurrentShape();
                if( oShape ){
                    var oMaterial = oShape.findMaterial( sName );
                    if( oMaterial ){
                        MessageBox.information("...FOUND MATERIAL","INFO","OK");
                        // var oPropertySettings = oSettings.getSettingsValue( "properties" );
                        
                        var oPropertySettings = new DzSettings();
                        if( oPropertySettings.fromString( sSettings ) ){
                            
                            MessageBox.information("Read of XML encoded data was successful.","INFO","OK");
                            print ("oPropertySettings = "+oPropertySettings);

                            if( oPropertySettings ){
                                MessageBox.information("...FOUND PROPERTY SETTINGS","INFO","OK");
                                var oMaterialProperty, oProxyProperty;
                                var sPropertyName, sProxyName;
                                
                                // Iterate over the properties
                                for( var i = 0, nProps = oPropertySettings.getNumValues(); i < nProps; i += 1 ){
                                    sPropertyName = oPropertySettings.getKey( i );
                                    MessageBox.information("Searching for "+sPropertyName,"INFO","OK");
                                    oMaterialProperty = oMaterial.findProperty( sPropertyName );
                                    if( oMaterialProperty ){
                                        MessageBox.information("...FOUND MATERIAL PROPERTY","INFO","OK");
                                        sProxyName = String("%1 %2 Proxy").arg( oMaterial.name ).arg( sPropertyName );
                                        sProxyName = oMaterial.name
                                        print ("sProxyName = "+sProxyName);
                                        //oProxyProperty = oNode.findProperty( sProxyName );
                                        oProxyProperty = oNode.findProperty( sPropertyName );
                                        if( oProxyProperty ){
                                            MessageBox.information("...FOUND PROXY PROPERTY","INFO","OK");
                                            if( oMaterialProperty.inherits( "DzNumericProperty" ) ){
                                                oMaterialProperty.linkTo(oProxyProperty);
                                                MessageBox.information("...SUCCESS!...","INFO","OK");
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            MessageBox.information("Could not read XML encoded data.","INFO","OK");
                        }
                    }
                }
            }
        }
    }
    MessageBox.information("...FINISHED","INFO","OK");

Edit: Note that if the "Vertical/Horizontal Offset"values on the Parameters tab and/or the Surfaces tab are given non-zero values before running the script, then the "Vertical/Horizontal Offset" values on the Surfaces tab will be set to match those on the Parameters tab after running the script. So those on the Parameters tab are the 'masters'. which makes sense from the DzNumericProperty::linkTo() documentation - you call the method on the slave property, and pass the master property,i.e. 'oMaterialProperty.linkTo(oProxyProperty);'

Undocumented propertysettings_dz - is this the same as the old DzSettings? What's a key string?

$
0
0

(I've copied this post from here as a new thread, since it's not really related to the Iray renderer except by the context in which I was asking the question)

Using Rob's Render Settings - Find Property sample code I've got the properties I want. Now I look under DzProperty and reckon I need to do getAttributes / setAttributes, but the essential propertysettings_dz is as yet undocumented. I guess it's similar to the old DS3 DzSettings? So with a bit of educated guesswork I set up oProperty using Rob's sample code with "Environment Intensity" as the string and do this...

                var oPsettings = new DzPropertySettings;
                oProperty.getAttributes( oPsettings )
                print('>>> oP "Environment Intensity" = ',oPsettings.getFloatValue())

...(I know getFloatValue requires parameters - I'm getting to that) and I get this...

DEBUG: Found: Environment Map
WARNING: Script Error: Line 1839
WARNING: SyntaxError: too few arguments in call to getFloatValue(); candidates are
    getFloatValue(QString)
    getFloatValue(QString,float)

In the old DS3 DAZ Script 2 documentation it gives this

Number DzSettings::getFloatValue ( String key, Number def = 0.0 )
Parameters:
        key     The key string.

QUESTION 1: What is "the key string" ?

QUESTION 2: Am I heading in the right direction ?

Creating a simple DzERCLink between two new parameters

$
0
0

My script creates two brand new parameters.

I want to connect them using an ERCLink, with a predefined scaling factor (old-school 'deltaAddDelta' with a factor of 0.5).

But how ? (Read the bottom part of the code to see my problem)

Here's the basics:

	
	// Set up the master property
	var oProperty1 = new DzIntProperty();
	oProperty1.name = "Texture Column (0 or 1)"
	oProperty1.setLabel( "Texture Column (0 or 1)" );
	oProperty1.setPath( "Book Selection" );
	oProperty1.setIsUserProperty( true );
	oProperty1.setNew( true );
	oProperty1.setMin(0);
	oProperty1.setMax(1);
	oProperty1.setIsClamped(true);
	oProperty1.setSensitivity(1);
	oProperty1.setValue(0);
	oNode.addProperty( oProperty1 );
	
	//Set up the slave property
	var oProperty2 = new DzFloatProperty();
	oProperty2.name = "Horizontal Offset"
	oProperty2.setLabel( "Horizontal Offset" );
	oProperty2.setPath( "Book Selection/Material Tiling Proxies" );
	oProperty2.setIsUserProperty( true );
	oProperty2.setNew( true );
	oProperty2.setDisplayAsPercent( false );
	var oPropertyAlreadyThere = findElementProperty( oNode, oProperty2.name );
	oNode.addProperty( oProperty2 );
	
	// Create a new DzERCLink (which inherits from DzNumericController and DzController)
	// It appears that both the constructor and 'setProperty()' connect the master...
	oERCLink = new DzERCLink(oProperty) // I assume that this is the master ? It doesn't appear to be the slave.
	oERCLink.setProperty(oProperty1) // "Sets the property that drives this link. " i.e. the master
	
	// So I assume that to set upthe slave I now have to add oERCLink as a 'controller' to oProperty2
	// DzProperty includes lots of '~~~~Controllers()' methods but I can't see any for ADDING a controller
	
	// ??? BUT HOW ???
	

This is related to my Creating dependencies between settings on the Surfaces tab and Parameters tab thread

How to set up pose parameter by script?

$
0
0

Hello.

Please, help me with these questions.

- How to set up Rotation parameter (Bend or Twist) of Left Forearm Bend of the selected figure?

- How to check selected figure is G8F?

Thank you.


Can you create Modeless Dialogs?

$
0
0

The dialogs I create from DzDialog or DzBasicDialog are modal, meaning that once it's displayed, you can't click on any Daz Studio controls.

Is there a way to create the modeless kind? I've checked out the DzPaneMgr interface, but couldn't find anything there (did I miss something?).

I've noticed that the DS Panes are like this, but can't find a way to replicate something like that.

Any help will be appreciated.

 

Changing sliders in "DzShapingPane"

$
0
0

Hey,

I'd like to change the value of the "Bodybuilder" slider (Shaping \ Editor \ All) by script, but I didn't find a way to do so. Is this an action? It doesn't show up inside "MainWindow.getActionMgr()" - at leat I can't find it. I also tried getting "DzShapingPane" and using ".getOptionsMenu()", but I unfortunately I don't know what to do next.

How do I get to the slider, or the action that it triggers?

Thank you for your help.

-Michael

 

Why is this function returning null?

$
0
0

Hi,

I'm having trouble understanding why this code is not working.  Basically I load a figure into the scene and select it.

The script is then supposed to find a bone with the word "abdomen" in it's name (and then select the bone).  The function 'findBone()' appears to be working correctly,

but it keeps returning null instead of a bone.  I've been staring at it until I'm cross-eyed and I still can't see why it's doing this:

(function() {
	var title = "Select Child Nodes",
			node = null,
			skel = null;
	
	// Find a bone containing 'str' in it's name:
	function findBone(parent, str) {
		var len = parent.getNumNodeChildren(),
			child = null;
		
		for (var i=0; i&lt;len; i++) {
			child = parent.getNodeChild(i);
			print("Checking: "+child.getName());
			
			if (child.getName().find(str) &gt;= 0) {
				print(child.getName() + " found!");
				return child;
			}
		
			findBone(child, str);
		}
	}
	
	try {	
		node = Scene.getPrimarySelection();
		
		if (!node)
			throw new Error("Select a bone in a figure");
		
		if (node.inherits("DzSkeleton"))
			skel = node;
		else if (node.inherits("DzBone"))
			skel = node.getSkeleton();
		else
			throw new Error("Select a bone in a figure");		

		var abdomen = findBone(skel, "abdomen");
		if (abdomen)
		  abdomen.select(true);
		else
			print("Bone Not Found!");
	}
	catch(err) {
		MessageBox.critical(err.message + "\n(line: " + err.lineNumber + ")",
												title, "&amp;OK" );
		return false;
	}
})()

 

UV image

$
0
0

Hi all.

I am trying to get an image or pixmap of the current UV set for a selected material, throught a script. Any ideas?

Mike

Find out if surface will be visible in render?

$
0
0

Is there a scripting way to find out if a surface will be visible in render?

Thank's in advance

 

Viewing all 1029 articles
Browse latest View live


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