0
$\begingroup$

what I am trying to do is registering my own image user (for node customization). Basically, I am trying to create a custom node group that can be an image user. Placing 'ShaderNodeTexImage' node into its node tree is not an option - the class itself must be able to hold the image and the image_user attributes. So, I attempted:

class experimental(bpy.types.ShaderNodeTexImage):
    bl_label = "this is experimental"

bpy.utils.register_class(experimental)

bpy.context.active_object.active_material.node_tree.nodes.new(type = 'experimental')

This does create a new node and register the class with no mistakes but I try

bpy.context.active_object.active_material.node_tree.nodes.active.[autocomplete]

it does not show the Image property (my subclass does not inherit the properties of the ShaderNodeTexImage). Why???

is there any other way to create an .image and .image_user properties for my custom class? in the ideal world, I would like to have something like:

class myClass(bpy.types.Node):

    img = bpy.types.Image(params)
    img_user = bpy.types.ImageUser(params)

Is there any way to achieve this?

$\endgroup$
6
  • $\begingroup$ Check out the custom nodes template in text editor. $\endgroup$
    – batFINGER
    Commented Mar 14, 2019 at 12:47
  • $\begingroup$ @batFINGER sorry, but I think, if one knows the answer, it would take 2 sentences to formulate it. at the first glance, custom_nodes.py has nothing to help me. $\endgroup$
    – Serhii
    Commented Mar 14, 2019 at 13:14
  • $\begingroup$ I think you need to take more than a first glance. For instance a registered class property in blender is never going to be img = bpy.types.Image(params) (do you think you can even instance an image that way in blender?) more likely would use img = bpy.props.PointerProperty(type=bpy.types.Image) Have no idea what the 2 sentences blah re my comment (yes a comment not an answer) is about.... don't think I want to know. $\endgroup$
    – batFINGER
    Commented Mar 14, 2019 at 14:20
  • $\begingroup$ @batFINGER no intention to insult you. of course I do know that bpy.types.Image(params) does not work - that was a syntactical example of what I would like to have. regarding PointerProperty: the pointer property type input must only be a sublass of PropertyGroup, whereby the PropertyGroup itself does not allow anything fancy. It's a mere container for palin properties. $\endgroup$
    – Serhii
    Commented Mar 14, 2019 at 14:31
  • $\begingroup$ BS The pointer property type can be an ID type. Also Related blender.stackexchange.com/questions/556/pynodes-the-bare-basics $\endgroup$
    – batFINGER
    Commented Mar 14, 2019 at 14:46

0

You must log in to answer this question.

Browse other questions tagged .