Blender 2.8 - Panel Location


#1

Hi All

I am writing an add-on for Blender 2.8. I am trying to get the panel to display in the render tab of the properties section.

In Blender 2.79, I believe this would have been as simple as:

bl_space_type = ‘PROPERTIES’
bl_region_type = ‘WINDOW’
bl_context = “render”

That doesn’t seem to work in Blender 2.8. I suspect it’s because the render tab now completely changes depending on what render engine you select. I don’t get an error, just no panel.

I suspect I need a different string for bl_context. I’ve tried everything I can think of - “rendercycles, render_cycles etc. etc.”. Nothing seems to work.

Can anyone help?

Cheers


#2

It should still work, we use identical code in Blender itself still. The render properties got split into render and output but it should appear in the first still.

Hard to say what might be the problem without more context, maybe the poll function is checking for Blender Internal or something like that.


#3

@brecht - Thanks for the extremely speedy response!

I am not using a poll() function. The only values I can get to work for bl_context are “material” and “object”.

bl_context = “render”, “output”, “world” etc. do not work for me (and I’ve tried them all). I must be doing something else wrong.

Full file is here in case it helps shed light on the situation.


#4

I tested “render” yesterday and it does still work. Load the “Simple Panel” example and change the bl_context to render.

@brecht is there a way to find all the bl_context options with python? Bl_context options not listed in the API and the only way I know to get those is browse the source code.


#5

@AFWS Sorry, but got to disagree with you there.

At your suggestion, I just did exactly that. Used the Simple Panel example from the Blender 2.8 API reference.

Same problem I have with my add-on. It will only appear in Object or Material. Every other value (“render”, “output” etc.) definitely doesn’t work (for me).

Bit out of my depth, but I assume it wouldn’t be Linux specific?


#6

@brecht @AFWS Screenshot just to provide I am not (completely) insane. I can only post one image as a new user, so I can’t show you that it does work with “object”.

This is using the Simple Panel example from the Blender 2.8 API.

I am using 609d4f5c92c7.


#7

Well, for starters you selected “scene” and not “render” in the Properties. If you tested the Simple Panel example, you will see it adds the “label” ,but not the other properties. I think this is because you might have to have your properties be the same context as the bl_context. I might be completely wrong about this.


#8

@AFWS No, that’s wrong. If you look closely at the screen shot, that’s the render tab in properties not scene (I circled it in Red). You will note that it always says “Scene” at the top, regardless of what tab you are on.

Again, if you look at the screen shot, I am using the Simple Panel example from here, and it defines all of the following (where I have changed bl_context to render as advised):

bl_idname = "OBJECT_PT_select"
bl_label = "Select"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
bl_options = {'DEFAULT_CLOSED'}

It still does not work. It only works if I change bl_context to “material” or “object”

So, sorry, that’s not correct. There is still an issue here.


#9

Yeah, you’re right. I was reading the “Scene” and thinking it wasn’t on the right tab. You can see here it creates a panel ,but doesn’t add anything with “bpy.context.object”. You start of with trying to add properties with "bpy.context.object, so I think this is why you don’t get anything. This is why I’m thinking, you can only draw properties as the same context as the bl_context.


#10

@AFWS thanks.

I think I understand your theory, but I can’t quite reconcile it. Especially as I can’t get the Simple Panel example to work (putting my own code aside for a moment).

Can you do me a favour? Can you just copy and paste that exact file somewhere I can get it? Pastebin or something?

Just want to check I’m not losing my mind.


#11

Right, I’m an idiot.

It was the sodding poll() function after all, just like @brecht originally suggested.

I created the file from an example, and I forgot the stupid thing was even there.

Deleting:

@classmethod
def poll(cls, context):
return (context.object is not None)

Solves my issue.

Thank you for the help everyone. Really appreciated.