Page MenuHome

Invalid Keying Set File (exported with keys containing a ref to 'Shader Nodetree' ID)
Closed, ResolvedPublic

Description

System Information
Linux Sabayon 64bit - Intel Quad Core Q9950 (6giga Ram) + AMD HD5870

Blender Version
2.70 and above up to 2.74 as far as I can tell, and may be some earlier versions as well.

Short description of error
Running a previously exported keyingset.py file in the text editor yields an error in a specific case. It happens when you have some keys belonging to the Shader Node editor (and probably the texture and compositing nodes as well).

Error:   File "/keyingset2.py", line 13
    id_0 = bpy.data.shader node trees["Shader Nodetree"]
                              ^
SyntaxError: invalid syntax

Exact steps for others to reproduce the error

(A blendfile with the script already loaded is available as a link at the end of the message)

Start a new project (Blender Internal or Cycles) with the default cube for instance, go to the material tab and enable "use node" for the current material.
Then in the node editor go with the mouse on whatever default value of any nodes, the color for instance or roughness and with the RMB menu do "Add to Keying set"
Go in the Scene Tab an the do "Export to File", then remove existing new keying set and open the text editor, load your "keyingset.py" file and run it, you should have an error because of this line:

id_0 = bpy.data.shader node trees["Shader Nodetree"]

Here is a full buggy keyingset.py file:

# Keying Set: ButtonKeyingSet
import bpy

scene = bpy.context.scene

# Keying Set Level declarations
ks = scene.keying_sets.new(idname="ButtonKeyingSet", name="Button Keying Set")
ks.bl_description = "3 materials"

ks.use_insertkey_needed = False
ks.use_insertkey_visual = False
ks.use_insertkey_xyz_to_rgb = True

# ID's that are commonly used
id_2 = bpy.data.shader node trees["Shader Nodetree"]
id_1 = bpy.data.shader node trees["Shader Nodetree"]
id_0 = bpy.data.shader node trees["Shader Nodetree"]

# Path Definitions
ksp = ks.paths.add(id_0, 'nodes["Diffuse BSDF"].inputs[0].default_value', index=-1)
ksp = ks.paths.add(id_1, 'nodes["Diffuse BSDF"].inputs[0].default_value', index=-1)
ksp = ks.paths.add(id_2, 'nodes["Diffuse BSDF"].inputs[0].default_value', index=-1)

I would like to ask for your attention to the fact that this keying set has been made with 3 keys from 3 different materials. As you may understand probably now there is a second more interesting dimension to the problem. Even if there were no unwanted spaces in the ID's, how blender could know which path belongs to which material ? The 3 ID's refer to the same unspecific "Shader Nodtree" node and this doesn't allow to differentiate the keys from the 3 different materials.

I have not done the test but a similar problem might occur with the Texture Nodes as well.

Event Timeline

J.P. P. (jpfep) raised the priority of this task from to 90.
J.P. P. (jpfep) updated the task description. (Show Details)
J.P. P. (jpfep) added a project: BF Blender.
J.P. P. (jpfep) edited a custom field.
J.P. P. (jpfep) added a subscriber: J.P. P. (jpfep).
Joshua Leung (aligorith) lowered the priority of this task from 90 to 50.Apr 20 2015, 4:42 AM

Part of the problem here is that node trees for materials are only "dummy" id-blocks which get nested inside the material datablock. A few others have similar problems too (i.e. textures and also compositing nodes IIRC). This causes lots of problems all over the place, since we almost always forget about these, and then find that they need special treatment. It looks like this is one of those cases :)