2
$\begingroup$

When you call bpy.ops.mesh.solidify() Blender will add the mesh but NOT show you the solidify dialog. To adjust it you have to press F6.

I assumed that adding bpy.ops.redo_last() afterwards would do the trick but I think this does not work as expected as no UI appears. And if I press F6 I think a UI opens that appears more to show the dialog for the class I defined and not the solidify command that is part of the class.

enter image description here

Do you have an idea how you have to script this so when executing the script the solidify command is executed and then the F6 menu for the solidify command will be displayed.

class SolidifyDialog(bpy.types.Operator):  
    bl_idname = "solidify.dialog"  
    bl_label = "Solidify Dialog"  
    bl_options = {'REGISTER', 'UNDO'}


    def execute(self, context):
        bpy.ops.mesh.solidify()
        bpy.ops.redo_last()
        return {'FINISHED'} 
$\endgroup$
3
$\begingroup$

Since you are wrapping the Solidify operator inside your operator :

  • create a property (variable ) to hold the thickness and pass it to the solidify operator.
  • create a draw() function and call it ( the F6 will also call this draw() function )
  • you can display the menu of your operator to control the solidify operator through the property.

import bpy
from bpy.props import FloatProperty


class SolidifyDialog(bpy.types.Operator):  
    bl_idname = "solidify.dialog"  
    bl_label = "Solidify Dialog"  
    bl_options = {'REGISTER', 'UNDO'}

    thickness = FloatProperty(
                name = "thickness",
                default = 0.001,
                min = -10,
                max = 10,
                unit ='LENGTH'   
                )
    def execute(self, context):
        bpy.ops.mesh.solidify(thickness = self.thickness)
        return {'FINISHED'} 

    def draw(self, context):
         layout = self.layout
         row = layout.row()
         row.prop(self,"thickness")

    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_popup(self, event)

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


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


if __name__ == "__main__":
    register()

note : wm.invoke_props_dialog() didn't work as expected , it doesn't update the view while changing the value so i switched to wm.invoke_props_popup()

$\endgroup$
  • $\begingroup$ Thank you very much, I have to study how this is structured. QUESTION Do you know how to display the unite system with this dialog like Metric or imperial? $\endgroup$ – Claas Kuhnen Jan 17 '16 at 18:40
  • $\begingroup$ @ClaasKuhnen edited the answer see unit ='LENGTH' $\endgroup$ – Chebhou Jan 17 '16 at 18:52
  • $\begingroup$ May I ask where you got this from? I ask because before posting I spend time online and in the Py API to find this myself but did not. $\endgroup$ – Claas Kuhnen Jan 17 '16 at 18:54
  • $\begingroup$ I have used it before, and you can find it in the API here blender.org/api/blender_python_api_2_74_0/… $\endgroup$ – Chebhou Jan 17 '16 at 18:56
  • $\begingroup$ I htink I should forget about using Google and only do this inside the Blender.org API website which has also a search field. Thank you very much! $\endgroup$ – Claas Kuhnen Jan 17 '16 at 19:00
2
$\begingroup$

While the correct operator name is bpy.ops.screen.redo_last() it fails when called from within an operator. As you are in the process of executing an operator the redo will want to refer to the current action being run not the sub action that just finished.

You may notice that if you remove the bl_options and call only the solidify operator then the redo will work on the action before your operator not the solidify that you would expect. This implies that as the undo stack only works on the last action performed, the redo does not support adjusting any sub actions.

$\endgroup$
  • $\begingroup$ If understand you correctly take the " bl_idname = "solidify.dialog" bl_label = "Solidify Dialog" bl_options = {'REGISTER', 'UNDO'}" out but keep the redo.last wrapped inside this operator? Or do you mean without the BL_ data and the redo.last inside the operator calling F6 afterwards will work. $\endgroup$ – Claas Kuhnen Jan 17 '16 at 17:07
  • $\begingroup$ If you remove the bl_options then run your operator and press f6, then the previous actions options will show not the solidify options that you call from your execute method. With the bl_options f6 will bring up your operator (with no options) not the solidify you called. But Chebhou figured a way past this. $\endgroup$ – sambler Jan 18 '16 at 6:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.