So I came across a little pickle whilst making a addon. I was making a "create object" type tool, which had a lofty number of custom properties, so I wanted both to organize it, and to figure out how to add a UI dropdown box that would allow to pick meshes from the scene, and re-use them as base meshes.

I did research as to how to make custom UI in my addons via the draw() function. I then implemented it, (The way I thought it worked.) and when I executed the custom addon, the custom tool WORKED but there were no bpy.props displayed. Here's my code at the time: (This isn't meant to have a toolbar hanging out in the 3d view all the time, but only show UI when the execute() function is called.)

#bl_info stuff here

import random
import bpy

class makeamazingthing(Operator):
bl_idname = "object.make_amazing_thing"
bl_label = "Make Amazing Thing"
bl_options = {'REGISTER','UNDO'}

prop1 = bpy.props.BoolProperty(name="Cool Prop", default=True)

def execute(self,context):
bpy.ops.object.delete(use_global=False)
return {'FINISHED'}

@classmethod
def poll(cls, context):     #  determine whether an object is active. (It's meant to replace base objects.)
ob = context.active_object
return ob is not None and ob.mode == 'OBJECT'

def draw(self,context): #This is used to draw the layout.
layout=self.layout
box = layout.box()
box.prop(self,'prop1')

self.layout.operator(makeamazingthing.bl_idname, icon='PLUGIN')

def register():
bpy.utils.register_class(makeamazingthing)

def unregister():
bpy.utils.unregister_class(makeamazingthing)

if __name__ == "__main__":
register()


Ok, I'm sorry if that's too much information, but I put it all up there because I have no idea what the problem is!! I've been doing research all day, watching and reading tutorials, but I can't find an answer!

For one, I'm not sure what to put in box.prop(self,'something?') under the draw() func. All the tutorials seem to be referring to the actual names with underspaces, and that didn't work. Not sure if it should.

Also in the original classname I tried adding the Panel toolbox along with the Operator toolbox;

class makeamazingthing(bpy.types.Operator,bpy.types.Panel):


(I know I could've just used bpy.types, but I didn't want to redo everything in the script right away.)

Also when everything failed, I tried commenting out the whole draw() function, getting rid of bpy.types.Panel in the class declaration, and UI STILL isn't showing! I assumed I reverted it to it's original state, but I guess not, because it isn't working.

Again, this isn't supposed to hang out in the toolbar, the UI is only meant to appear beneath the 3d view toolbox whenever the tool is actually used.

So any help to get this working again, with or without the fancy UI would be much appreciated. And... any help as to get that dropdown menu that would allow me to pick an object from the scene would be much appreciated as well, but that's a lesser priority right now.

EDIT: OK I figured out what's wrong, but I'm still a little stuck, and this can still be useful for others who come across the same issue!

so the problem was the poll function (after @classmethod) where it tests to see if an object is selected before allowing the execute() function to even be available. At the end of the execute() function I was deleting the selected object. Basically, I killed my own poll() function and caused it to collapse on itself. So now... I need to figure out how to make a selected object contextually relevant in order to allow the tool to even be available for use in blender, and still manage to delete it near the end of execute()... without it flopping on itself.

I will continue digging, and my problem is virtually solved, but any help will still be much appreciated!

• can you post your full code, because the code you posted does not run. wm_operator_invoke: invalid operator call 'OBJECT_OT_make_structure' Dec 9, 2015 at 6:20
• Sorry, I didn't repost my whole script because it's a bit long, but I fixed the posted code! And I figured out a bit from fixing it. Post has been updated. Dec 11, 2015 at 1:52

The poll() function was cutting out my UI, because it was checking if something was selected before allowing my addon to run, and I was deleting my selected object at the end of my execute() function.
Therefore, to fix it I simply selected one of the newly created objects (the original code creates several new objects) and THEN unlinked the original object. So something is always selected, therefore, poll() thinks the context is still correct, therefore letting my UI to continue displaying.