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$
  • $\begingroup$ Check out the custom nodes template in text editor. $\endgroup$ – batFINGER Mar 14 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$ – SerhiiPoklonskyi Mar 14 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 Mar 14 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$ – SerhiiPoklonskyi Mar 14 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.