They both work from the editor.
This installs fine:
import bpy
from bpy.types import Panel
#Class for the Panel, Derived by Panel
class SimpleToolPanel(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_label = 'Add Assorted Objects'
bl_context = 'objectmode'
bl_category = 'Objects_Add'
#Add UI Elements here
def draw(self, context):
layout = self.layout
layout.operator('mesh.primitive_solid_add', text = 'Add Regular Solids', icon='MESH_ICOSPHERE')
layout.operator('mesh.primitive_xyz_function_surface', text = 'Add XYZ Function Surface', icon='OUTLINER_DATA_SURFACE')
layout.operator('curve.torus_knot_plus', text = 'Add Curve - Torus Knot Plus', icon='MESH_TORUS')
layout.operator('mesh.generate_geodesic_dome', text = 'Add Geodesic Dome', icon='MESH_ICOSPHERE')
#Register
def register():
bpy.utils.register_class(SimpleToolPanel)
#Unregister
def unregister():
bpy.utils.unregister_class(SimpleToolPanel)
#Needed to run script in Text Editor
if __name__ == '__main__':
register()
this, doesn’t:
#----------------------------------------------------------
# File: tools_menu_Xtra_Objects.py
#----------------------------------------------------------
bl_info = {
"name": "Xtra Objects",
"version": (0, 0, 1),
"location": "View3D > Tool Shelf",
"description": "Add Objects - Mesh, Curves",
"category": "Object"}
import bpy
# Layout panel
#class SimpleToolPanel(Panel):
# bl_space_type = 'VIEW_3D'
# bl_region_type = 'TOOLS'
# bl_label = 'Xtra Objects'
# bl_context = 'objectmode'
# bl_category = 'Xtra_Objects'
class LayoutPanel(bpy.types.Panel):
bl_label = "Xtra Objects"
bl_space_type = "VIEW_3D"
bl_context = 'objectmode'
bl_region_type = "TOOLS"
def draw(self, context):
layout = self.layout
layout.label("Diamonds")
row = layout.row(align=True)
# row.alignment = 'EXPAND'
row.alignment = 'LEFT'
row.operator('mesh.primitive_brilliant_add', text = 'Brilliant', icon='PMARKER_ACT')
row.operator('mesh.primitive_diamond_add', text = 'Diamond', icon='PMARKER_ACT')
row.operator('mesh.primitive_gem_add', text = 'Gem', icon='PMARKER_ACT')
layout.label("Other Objects")
row = layout.row(align=True)
# row.alignment = 'EXPAND'
row.alignment = 'LEFT'
row.operator('mesh.add_beam', text = 'Beam Builder', icon='OUTLINER_DATA_MESH')
row.operator('mesh.wall_add', text = 'Wall Factory', icon='OUTLINER_DATA_MESH')
row = layout.row(align=True)
# row.alignment = 'EXPAND'
row.alignment = 'LEFT'
row.operator('mesh.primitive_star_add', text = 'Simple Star', icon='OUTLINER_DATA_MESH')
row.operator('mesh.primitive_steppyramid_add', text = 'Step Pyramid', icon='OUTLINER_DATA_MESH')
row.operator('mesh.honeycomb_add', text = 'Honeycomb', icon='OUTLINER_DATA_MESH')
row.operator('mesh.primitive_teapot_add', text = 'Teapot', icon='OUTLINER_DATA_MESH')
# Button
class OBJECT_OT_Button(bpy.types.Operator):
bl_idname = "my.button"
bl_label = "Button"
number = bpy.props.IntProperty()
row = bpy.props.IntProperty()
loc = bpy.props.StringProperty()
def execute(self, context):
if self.loc:
words = self.loc.split()
self.row = int(words[0])
self.number = int(words[1])
print("Row %d button %d" % (self.row, self.number))
return{'FINISHED'}
#Register
#def register():
# bpy.utils.register_class(LayoutPanel)
#Unregister
#def unregister():
# bpy.utils.unregister_class(LayoutPanel)
# Registration
#bpy.utils.register_module(__name__)
#Needed to run script in Text Editor
if __name__ == '__main__':
register()
They both started out here:
Blender Addons with Python Tutorial:
and got (cut and paste, tweaked) mashed up with this:
>> Panel layout and several arguments <<
(layout.py)
Dev:Py/Scripts/Cookbook/Code snippets/Interface
https://wiki.blender.org/index.php/Dev:Py/Scripts/Cookbook/Code_snippets/Interface
I’ve tried several variations based on what I can find from Search (web).
Nothing seems to be working.
Using 2.78. Everything accessed is built in to 2.78.
I’m stumped.