Thanks for the response. Yes, it seems like the UI Menu or UI Menu Simple is the way to go, but how do I lay-out them in a âcolumnarâ manner like the Ctrl+Shift+C above?
You can use the draw function to mess with the layout, adding columns or adding line items to the same rows, etc. So you define the draw function in your class and reference your different elements inside it. This might help a bit:
Thanks again for the response but for some reason the draw function doesnât work on the UI Template.
I tried adding the layout.prop but it does not work. It also doesnât error out.
Here is the code so far:
import bpy
class SimpleCustomMenu(bpy.types.Menu):
bl_label = "Simple Custom Menu"
bl_idname = "OBJECT_MT_simple_custom_menu"
text = bpy.props.StringProperty(name="Enter Text", default="")
scale = bpy.props.FloatProperty(name="Scale", default=1)
rotation = bpy.props.BoolProperty(name="Z Up", default=False)
center = bpy.props.BoolProperty(name="Center Origin", default=False)
extrude = bpy.props.BoolProperty(name="Extrude", default=False)
extrude_amount = bpy.props.FloatProperty(name="Extrude Amount", default=0.06)
def draw(self, context):
layout = self.layout
layout.label(text="Sample Text")
layout.prop(self, "text")
layout.prop(self, "scale")
layout.prop(self, "rotation")
layout.prop(self, "center")
layout.prop(self, "extrude")
layout.prop(self, "extrude_amount")
#layout.operator("wm.open_mainfile")
#layout.operator("wm.save_as_mainfile")
def register():
bpy.utils.register_class(SimpleCustomMenu)
def unregister():
bpy.utils.unregister_class(SimpleCustomMenu)
if __name__ == "__main__":
register()
# The menu can also be called from scripts
bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)
Thanks for the reply. I tried your code but the result is exaclty the same when I execute it within Blender. (i.e. No error but no additional menu added either).
Thanks for the response. Regarding on registering properties to add to the pop-up menu.
Please see revised code below. Iâll tag now the thread as complete. Iâll just create a separate thread on them.
Thanks again!
import bpy
class MaterialSettings(bpy.types.PropertyGroup):
text : bpy.props.StringProperty(name="Enter Text", default="Enter Text")
scale : bpy.props.FloatProperty(name="Scale", default=1)
rotation : bpy.props.BoolProperty(name="Z Up", default=False)
center : bpy.props.BoolProperty(name="Center Origin", default=False)
extrude : bpy.props.BoolProperty(name="Extrude", default=False)
extrude_amount : bpy.props.FloatProperty(name="Extrude Amount", default=0.06)
class SimpleCustomMenu(bpy.types.Menu):
bl_label = "Simple Custom Menu"
bl_idname = "OBJECT_MT_simple_custom_menu"
def draw(self, context):
layout = self.layout
scene = context.scene
mytool = scene.my_tool
layout.prop(mytool, "scale")
layout.prop(mytool, "rotation")
layout.prop(mytool, "center")
layout.prop(mytool, "extrude")
layout.prop(mytool, "extrude_amount")
classes = [MaterialSettings, SimpleCustomMenu]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=MaterialSettings)
def unregister():
for cls in classes:
bpy.utils.register_class(cls)
del bpy.types.Scene.my_tool
#register, unregister =
if __name__ == "__main__":
register()
# The menu can also be called from scripts
bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)
Hi , yes the my code only works if you have an active object with an assigned material, this way the settings are âper materialâ, otherwise you can register to the scene class to make it accessible at any time in the scene, it really depends what youâre wanting to achieve. All the best.