1

I want to create a very simple add-on that will automatically call some code (e.g. see example below) that will create a custom group node to be available in the compositor. What should the simple add-on look like? Apparently this code cannot be executed in the register() of the add-on due to the following error: AttributeError: '_RestrictData' object has no attribute “node_groups”. So where should such code be automatically be called within the add-on?

def createGroupNodes():
  # create a COMBINE XYZ group
  vector_group = bpy.data.node_groups.new('CombineXYZ', 'CompositorNodeTree')

  # create group INPUTS
  group_inputs = vector_group.nodes.new('NodeGroupInput')
  group_inputs.location = (-300,0)
  vector_group.inputs.new('NodeSocketFloat','X')
  vector_group.inputs.new('NodeSocketFloat','Y')
  vector_group.inputs.new('NodeSocketFloat','Z')

  # create group OUTPUTS
  group_outputs = vector_group.nodes.new('NodeGroupOutput')
  group_outputs.location = (300,0)
  vector_group.outputs.new('NodeSocketVector','Vector')

  # create three math nodes in a group
  node_combine = vector_group.nodes.new('CompositorNodeCombRGBA')
  node_combine.location = (000,0)

  # link inputs
  vector_group.links.new(group_inputs.outputs['X'], node_combine.inputs[0])
  vector_group.links.new(group_inputs.outputs['Y'], node_combine.inputs[1])
  vector_group.links.new(group_inputs.outputs['Z'], node_combine.inputs[2])

  #link output
  vector_group.links.new(node_combine.outputs[0], group_outputs.inputs['Vector'])
DolphinDream
  • 841
  • 6
  • 21
  • related with explanation of _RestrictData error http://blender.stackexchange.com/questions/8702/attributeerror-restrictdata-object-has-no-attribute-filepath/8732#8732 – zeffii Aug 06 '15 at 06:01
  • see here the equivalanet app.handler you could use http://blender.stackexchange.com/a/23230/47 – zeffii Aug 06 '15 at 06:12
  • 2
    related: http://blender.stackexchange.com/questions/5813/is-it-possible-to-execute-an-add-on-when-choosing-new-to-open-the-default-file?rq=1 (possible duplicate) – zeffii Aug 06 '15 at 10:13

0 Answers0