set blender scene
parent
d0cc3ac4a7
commit
9612122b5f
29
core/node.py
29
core/node.py
|
@ -18,6 +18,7 @@ class Node:
|
||||||
self.parameters = []
|
self.parameters = []
|
||||||
|
|
||||||
self._parent = None
|
self._parent = None
|
||||||
|
self._scene = None
|
||||||
|
|
||||||
for prop in self.bl_node.bl_rna.properties:
|
for prop in self.bl_node.bl_rna.properties:
|
||||||
if prop.is_readonly:
|
if prop.is_readonly:
|
||||||
|
@ -82,6 +83,32 @@ class Node:
|
||||||
if self._parent:
|
if self._parent:
|
||||||
self.bl_node.parent = self._parent.bl_node
|
self.bl_node.parent = self._parent.bl_node
|
||||||
|
|
||||||
|
@property
|
||||||
|
def scene(self):
|
||||||
|
"""Get the name of the scene used by the node.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: scene name.
|
||||||
|
"""
|
||||||
|
if self._scene:
|
||||||
|
return self._scene.name
|
||||||
|
|
||||||
|
@scene.setter
|
||||||
|
def scene(self, value):
|
||||||
|
"""Set the blender scene using the bpy Scene object or its name.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
value (str|bpy.types.Scene): scene name or scene object to set th the node.
|
||||||
|
"""
|
||||||
|
if isinstance(value, str):
|
||||||
|
self._scene = bpy.data.scenes[value]
|
||||||
|
|
||||||
|
elif isinstance(value, bpy.types.Scene):
|
||||||
|
self._scene = value
|
||||||
|
|
||||||
|
if self._scene:
|
||||||
|
self.bl_node.scene = self._scene
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, data, tree):
|
def from_dict(cls, data, tree):
|
||||||
"""Create all nodes from their dict representation.
|
"""Create all nodes from their dict representation.
|
||||||
|
@ -102,7 +129,7 @@ class Node:
|
||||||
setattr(node, p, data[p])
|
setattr(node, p, data[p])
|
||||||
|
|
||||||
# set attribute on the blender node only if correct type is retrieve
|
# set attribute on the blender node only if correct type is retrieve
|
||||||
if p not in ('parent',):
|
if p not in ('parent', 'scene'):
|
||||||
setattr(node.bl_node, p, getattr(node, p))
|
setattr(node.bl_node, p, getattr(node, p))
|
||||||
|
|
||||||
node.inputs = [Input.from_dict(ipt_data, node) for ipt_data in data['inputs'].values()]
|
node.inputs = [Input.from_dict(ipt_data, node) for ipt_data in data['inputs'].values()]
|
||||||
|
|
Loading…
Reference in New Issue