Assign new diffuse map using IDE Script

Hello!

 

I would like to assign a new map / image file to a certain Surface.

I would really like to do this by Script.

However, I'm lost on how to that, and I didn't find any example for this.

There's no "Record" button for a macro like in Microsoft Word where one can inspect the recorded macro, is there?

 

Thank you very much!

Comments

  • SixDsSixDs Posts: 2,384
    edited September 2017

    It would be helpful if you could tell us something of the specific item you are working on. If this is purely a generic question, the answer depends on the latter. However, assuming that you are referring to typical, more recent DAZ content, that content is usually loaded using a .duf (DSON) file, which tells DAZ Studio what to load and any settings that accompany the item. The .duf files are merely compressed text files and be open and viewed in a text editor after uncompressing them using a utility such as 7zip, etc. So, if you can find your way through the script conventions used, you could/should be able to find the image file reference and change it, perhaps saving the result with a different filename in order to preserve the original.

    BTW, another option is to simply open the item in DAZ Studio, change the image maps in the Surfaces tab along with any other settings that you wish, and save it as a Material(s) preset.

    Post edited by SixDs on
  • jag11jag11 Posts: 885

    You'll need something just like this:

    (function() {	var textureFilename = null;	var texture = null;	var node = null;	var shellObject = null;	var shape = null;	var material = null;	var property = null;		/* get selected figure/prop/object/whatever */	if(!(node = Scene.getPrimarySelection())){		print("Great! nothing to do.");		 return;	 };	 	shellObject = node.getObject();	shape = shellObject.getCurrentShape();	material = shape.findMaterial("Face");	property = material.findProperty("Diffuse Color");		if (null != property) {		if (property.isMapped()) {			texture = property.getMapValue();			/* get current texture path */			textureFilename = texture.getFilename();			print("current difusse map:", textureFilename);		}				/* set texture map */		property.setMap(textureFilename); /* <-- set your new difusse map" */	}})();

     

Sign In or Register to comment.