I would like to code multiple functions (operations?) to a single button that is on a Display panel within the 3D viewport, and which will have toggle functionality. This is what I have so far. I'd like that when the button is pressed it adds a Subsurf modifier (with both Render & Viewport Subdivisions set to 2), and shade_smooth turned on for the selected object. When the button is pressed again the subsurf is deleted and the shade_smooth is turned off (shade_flat). As it stands now when the button is pressed again it just adds another Subsurf. I might also like to assign a hotkey to it. Any thoughts? Working with Blender 2.83.3
row = layout.row() row.operator("object.modifier_add", text= "Subsurf", icon = "MOD_SUBSURF").type="SUBSURF"
Here's a larger portion of the script:
class CustomPanel(bpy.types.Panel): """A Custom Panel in the Properties Toolbar""" bl_label = "V3" bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' def draw(self, context): layout = self.layout obj = context.object row = layout.row() row.prop(bpy.context.space_data.overlay, 'show_cursor', text = "3D cursor", toggle = True) row = layout.row() row.operator("object.modifier_add", text= "Subsurf", icon = "MOD_SUBSURF").type="SUBSURF" def register(): bpy.utils.register_class(CustomPanel) def unregister(): bpy.utils.unregister_class(CustomPanel) if __name__ == "__main__": register() ```