Setting node group input values of a material

I have created a set of parameterized stone materials all of which share the same parameter names.

The materials respond as expected to manually changing the parameter values as shown below.


However, I have not been able to change the parameters through the API. The code below is an
attempt to set the parameters. Also shown is the console output from that code. The two blocks
so produced are identical both having the default values.



The saturation input is set before and after the new material was created just to be sure…

Much thanks for any clues.

Well of course that doesn’t work.

No not working. Spent another day searching for clues and not getting very far. But thanks for the link, a lot there so it will take a while to sift through it. I’ll definitely post if I get it working.

uplload file if you can

quickly
mat copy i thnk wont create a new mat it is only referenced!

also you use same group name !
i doubt it is the same name must be like XYZ.001 ect…

amd also need to change the node tree for the new mat!

look at the script in link given
carefull only the one with index works ok !

happy bl

The attached file demonstrates (I,think) that mat.copy() does create a new instance, not just a reference.

The node_group code is for a helper method that will set the material->Surface input values by stochastics once I find out how to set them through the API. The code that creates and duplicates blocks is not dependent on that code. The script is not an addon yet. When you open the file the Text window should open with the script ready to run. After running the Ashlar Wall Builder panel should appear. Click “Create a new ashlar wall”. When the panel expands click on “Make Unique Stone Block” at the bottom. It should create two blocks (in the same position) at the 3D cursor.

Much thanks

Edit:

The two functions at the bottom are just there for reference while I see if they contain any clues. Theye were copied from the Blender UI

Attachments

WallBuilder001.blend (2.01 MB)

sorry this seems to create an ob but no verts at all!
why is it so big with only 4 cubes?

tell me what and where to add things
and i’ll do it !

the func is in the class

class OBJECT_OT_MakeBlockButton(bpy.types.Operator): ?

will look at code later on

thanls

The wall created when you click the “Create a new ashlar wall” is an abstraction that holds data about the wall as a whole. When the script is completed the individual blocks will be joined to the wall to share its origin. At preset it only makes one block at a time and places every block in the same place. As you may have noticed there is no provision for providing any description of the wall’s dimensions. That will come later. I’m just trying to get it to work one little step at a time. The blocks initially present in the scene when you open the file are just artifacts of previous tests.

“why is it so big with only 4 cubes?”

Yes it’s in the execute function. I will later refactor that.

just began looking at your code
and you are using bpy node !

all the example i have use the tree node including the one in the link given for group node
and even for this method some seems to still be buggy
so don’t really have example using bpy …
but it should work

i’ll see if i can find some error if not a bug!

thanks
happy cycles

just saw some strange error right at beginning

dont’ think it is even running !

i’m on window


rror: Cannot find wingdb.py in $(WINGHOME)/bin or $(WINGHOME)/src

rror: Please check the WINGHOME definition in wingdbstub.py
shlarWallBuilderPanel draw || MODULE_MODE == standby
shlarWallBuilderPanel draw || MODULE_MODE == standby

is this a special module ?

thanks

dont’ know what it gives this error

but i was able to add the nodes and block
so i’ll see if i can make it works

group node is added and other input nodes too!
but no links !

one thing when adding a new block it makes a copy of the group node
but it is not unique it is a link material or node!

thanks

The error is related to an IDE I was trying out. In the text window drop down try deleting “wingdbstub.py”

“one thing when adding a new block it makes a copy of the group node
but it is not unique it is a link material or node!”

I found a bug in the file I uploaded and fixed and re-uploaded. Try down loading it again and see if the problem is corrected.

If you open the Surface panel after selecting Materials in the properties window you will see the input parameters to the selected block. If you modify those only the properties of the selected block change.

I no nothing of the internals but all I need to be unique per block are the inputs to the node _group. I don’t care if it is the same block
of code executing (with different input parameters) for each stone-block.

thanks

well right now the group node is not unique for each block it is link
so there must a command to make it unique after doing your copy!

here are the command for inputs / outputs link

group node

bpy.data.node_Group[“Shader Nodetree”].nodes[“Limestone_1”].inputs[1].default_Value

input nodes

bpy.data.node_Group[“Shader Nodetree”].nodes[“TextureControl”].outputs[0].default_Value

bpy.data.node_Group[“Shader Nodetree”].nodes[“Hue1Control.001”].outputs[0].default_Value

bpy.data.node_Group[“Shader Nodetree”].nodes[“SaturationControl”].outputs[0].default_Value

bpy.data.node_Group[“Shader Nodetree”].nodes[“Value”].outputs[0].default_Value

so you need to add these to make the different links
problem you also have to find how to identify these input nodes!

happy bl

don;t know why you dont’ get this error
but i also had to remove this one

rror:
\WallBuilder3.blend estScript3.py", line 323
mat_copy = mat.copy()
^
abError: inconsistent use of tabs and spaces in indentation

getting late for me
will continue tomorrow
see if you can add these new links
then it should work

thanks

Oh, … I too had that problem and owe
you my apologies, I made one last little change to a variable name
for the sake of clarity and simply neglected to test it. I do seem
to be a bit more squirrelly as I approach my dotage. I am very
sorry.

But I thank you very much for your assistance. In the
morning I will begin working on the code references provided in your
previous post.

Glandalf

interesting project you have here!

if you search latest SVN in scripts folder section
there is a init.py file with an example for composite nodes but not for cycles
but it shows how to make group and links

ex:

        bpy.data.materials["mat_lib_preview_material"].node_tree.links.new(output_node.inputs['Surface'], emission_node.outputs['Emission'])
        bpy.data.materials["mat_lib_preview_material"].node_tree.links.new(emission_node.inputs['Color'], image_node.outputs['Color'])

hope this can help to make your links!

also did not see how the links was done between the group node and the out material node in your little script yet !

let me know how it goes

thanks

look at you link for old castle
and not certain how you want to do your script and what this magik soft is

but have you seen cycles way of doing random material/ texture using info node with random location?
you just have to copy ob and it will make a random mat/text very simple

is this part of a school project ore research project ?

happy cycles

for this project how many individual stones are you talking here?
like 100 or a few 1000’s ?
if more then 1000 it might heavy on render time or memory!
might be easier and much faster to make a wall as one object and use an UV image!

by the way you know there is already a script to make rectangular stones wall
but not with cycles nodes
and if you add like a few 100 stones it gets heavy and sluggish quickly!

thanks

i added some links to the group node
and read the bpy command from the 3D node editor
sorry may be i made a mistake on writting it!

did you find the init.py file in script folder?
might give you some ideas here

and i think he use name like node_group also which is kind of misleading
but this will give only the value and should be able to change it also

did you try with the other example for adding link ?

you can use print dir ()
to get options for a command
but does not give everything!

print (‘dir =’,dir(node_group.inputs[2]))

[‘doc’, ‘module’, ‘slots’, ‘bl_rna’, ‘bl_socket_idname’, ‘defa
ult_value’, ‘draw’, ‘draw_color’, ‘identifier’, ‘in_out’, ‘max_value’, ‘min_valu
e’, ‘name’, ‘rna_type’, ‘type’]

so there is a defautl value here!

thanks

when you print the inputs values after changing it
it is empty
in other word it does not exist or has not been updated may be!

sorry i know how to do it with tree node like in german script
but struggling with this bpy.data!
have not relly seen cycles script using bpy data yet


thanks

No I have not seen the random location. But I will look for that --got a clue word or phrase for me to google? Changing the origin of a procedural texture relative to the mesh origin, if that is what random location is, is, I believe, necessary but not sufficient for my needs.

No I am not a student LOL. I’m an old fart retired and wrinkled. I have had bits of a story involving myths, Minoan culture (~1600 BC), and bull leaping (which is something like this: http://www.youtube.com/watch?v=caWVAJVFbrY) floating around in my head for many years and I’m trying to distill the bits into a coherent story. I’ve arranged to spend a couple of weeks on Crete next spring to research the infrastructure of Knossos and photograph the countryside around the palace/temples of Knossos and Phaistos and to soak up the ambience of the Aegean. Then next summer I will do a story outline and decide how to realize it–thinking about an “audio narrated graphic-novel” experimental kind of thingy. Have no Idea if I will live long enough to complete this–just wanted to start one last journey before age reduces me to a drooling idiot.