I want to create addon that convert curve object to mesh object, so poll function is checking if the selected object is curve. The code is some kind like this:
def poll(cls, context):
# check if curve is selected
obj = context.active_object
return obj and obj.type == 'CURVE'
The problem using this pool is if I run the operator, the properties of the operator doesn’t show up in bottom left corner, like in picture below.
If I don’t use the poll, it will be showed up like this.
Maybe it’s because the context is immediately fails because of the pool. I really want to add few properties in my operator but I don’t want to accidentally convert already mesh object.
I think your use of “context” instead of “bpy.context” may be the issue. “context” in your poll function seems to be a global variable, that is assigned somewhere else in your script. That somewhere else is probably being executed when you (or blender on start up) run the script, and just has a different context.
It’s still doesn’t work. The context is default for poll function, I don’t think it effects anything. The issue is because the object is immediately become a mesh if I use the operator, so the context is automatically fails.
No, it’s fine then, both are required to make the redo panel work. Also, the operator needs to be run from the 3D View context (e.g. spacebar menu), it will fail if you run the operator from Python console or Text Editor.
Thanks for the idea. This actually can be the solution, but the operator still can be called from ‘space’ search menu. It’s still consider okay because the execute function still can check the context.
However, it’s still a lot to do than just a poll function that behaved correctly. I might think this was a bug, I think I need to report it.
If you add ‘INTERNAL’ to bl_options, the operator won’t be listed in the spacebar menu, but can still be added to a panel, executed and with Redo panel working.