Need help wiht addon for 2.8

when you run one of the template in 2.8
where does panels or menu appear ?

don’t see any tool panel

so where is it ?

thanks for any feedback
happy bl

I want the equivalent of the old menu to call a class with the ID name

here is template for ui_menu

but it does not recognise the BL Id name ?

class CustomMenu(bpy.types.Menu):

bl_label = "Custom Menu"
bl_idname = "OBJECT_MT_custom_menu"

def draw(self, context):

	layout = self.layout
	
	layout.operator("mesh.primitive_archimedean_spiral1_add",
		text="archimedean_spiral1")

	layout.operator("wm.open_mainfile")
	layout.operator("wm.save_as_mainfile").copy = True

how can this work in 2.8 ?

thanks
happy bl

Maybe Sidebar? Didn’t know you could add tabs until the other day. Noticed this was even possible with 2.79.

import bpy


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Sidebar"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Hello'
    
    
    def draw(self, context):
        layout = self.layout

        obj = context.object

        row = layout.row()
        row.label(text="Hello world!", icon='WORLD_DATA')

        row = layout.row()
        row.label(text="Active object is: " + obj.name)

        row = layout.row()
        row.operator("mesh.primitive_cube_add")


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


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


if __name__ == "__main__":
    register()

but I need to re create the call to an operator class
like in 2.79
using the Add mesh menu then select operator and execute it

need menu with several operators
menu could be added anywhere
but it has to be able to call many operators
to add different meshes ect…

right now it does like my old script in 2.79 format
got error for msg !
but no indication on which line !

how do you pack the file ?
my test file is too big

test3.blend (113.3 KB)

try to run the script
hope it can be corrected

thanks

trying to run this template

operator_mesh_add.py

where is the panel for this with the properties ?

thanks
happy bl

There’s no panel in the code. You can find it at Add > Mesh > Add Box

that is a good one to add one box
one problem is that as soon as you change one property
the script disappear in the text editor

this must be a bug !

now is there a way to add a second level menu
in the add > Mesh

instead of add box it would be another menu then call different operators
with properties

thanks
happy bl

Like this?

import bpy


class MyCustomMenu(bpy.types.Menu): 	 
	bl_label = "My Menu"	   
	bl_idname = "OBJECT_MT_my_custom_menu"
		
	def draw(self, context):
		layout = self.layout							 
		layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE')
		layout.operator("mesh.primitive_cone_add", icon='MESH_CONE')
		layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE')  		   
		
def MyCustomMenuAdd(self, context):
	self.layout.menu(MyCustomMenu.bl_idname)

def register():
	bpy.utils.register_class(MyCustomMenu)
	bpy.types.VIEW3D_MT_mesh_add.append(MyCustomMenuAdd)

def unregister():
	bpy.utils.unregister_class(MyCustomMenu)
	bpy.types.VIEW3D_MT_mesh_add.remove(MyCustomMenuAdd)
	
if __name__ == "__main__":
	register()

multiple menu works now

got a problem with my old operator

class Archimedean_spiral1(bpy.types.Operator):

'''Add Archimedean Spiral'''




bl_label = "Archimedean Spiral"
bl_idname = "OBJECT_PT_helo1"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Hello'





seg1 : IntProperty(name="Segments", description="Number  segments", default=16, min=4, max=100)
nturn : FloatProperty(name="nturn", description="nturn",default=2.5, min=0.1, max=100.0)
ht : FloatProperty(name="Height/turn",description="Height/turn", default=0.0, min=0.0, max=100.0)
a1 : FloatProperty(name="a1",description="a1",default=0.1, min=0.001, max=100.0)

def execute(self, context):

	global  layers
	verts,edges,faces,vid= [],[],[],0
	bm = bmesh.new()									# Create new Bmesh mesh
	named1="Archimedes Spiral1"

	seg1 = self.properties.seg1
	nturn = self.properties.nturn
	ht = self.properties.ht
	a1 = self.properties.a1

cam you detect anything wrong with this
I get a Msg error somehow

thanks
happy bl

how do you call the class operator form menu

layout.operator(“OBJECT_PT_helo1.bl_idname”, icon=‘MESH_CUBE’)

my class is defined like this

class Archimedean_spiral1(bpy.types.Operator):

'''Add Archimedean Spiral'''


bl_idname = "OBJECT_PT_helo1"
bl_label = "Archimedean Spiral"

bl_options = {'REGISTER', 'UNDO'}

thanks
happy bl

Is that all the code? Nothing seems to happen. It doesn’t give a error now ,but doesn’t do anything either.

import bpy, bmesh


class OBJECT_OT_Archimedean_spiral1(bpy.types.Operator):
	"""Tooltip"""
	bl_label = "Archimedean Spiral"
	bl_idname = "object.archimedean_spiral1"
	bl_options = {'REGISTER', 'UNDO'}


	seg1 : bpy.props.IntProperty(name="Segments", description="Number  segments", default=16, min=4, max=100)
	nturn : bpy.props.FloatProperty(name="nturn", description="nturn",default=2.5, min=0.1, max=100.0)
	ht : bpy.props.FloatProperty(name="Height/turn",description="Height/turn", default=0.0, min=0.0, max=100.0)
	a1 : bpy.props.FloatProperty(name="a1",description="a1",default=0.1, min=0.001, max=100.0)


	def draw(self, context):
		layout = self.layout

		layout.prop(self, "seg1")
		layout.prop(self, "nturn")
		layout.prop(self, "ht")
		layout.prop(self, "a1")

				
	def execute(self, context):

		global  layers
		verts,edges,faces,vid= [],[],[],0
		bm = bmesh.new()									# Create new Bmesh mesh
		named1="Archimedes Spiral1"

		seg1 = self.properties.seg1
		nturn = self.properties.nturn
		ht = self.properties.ht
		a1 = self.properties.a1

		return {'FINISHED'}


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


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


if __name__ == "__main__":
	register()

you need to add the register for all the classes

I got to try to general one
got too many class in some script

register , unregister = bpy.utils.register_classes_factory(classes)

Add-Menu-Mesh1.blend (113.5 KB)

try this one
my new class is not shown
may be name no registered or bad name for class

thanks
happy bl

my function to add mat might also have some bug
for linking object to scene
which I think has change also for the collection things !

thanks
happy bl

Yeah, not sure what your code does ,but it does nothing in 2.79 either.

this is not for 2.79 has to be run in 2.8 only

I have a 2.79 version and it works fine

but as I said the add mat function is still for 2.79
has to be modified to work in 2.8

but first has to call the class operator !

thanks
happy bl

You got me confused now, LOL

last file I uploaded is for 2.8
cannot be run in 2.79

but I still have one function inside that has not been converted to 2.8
the add material at beginning of script

but for now there is still a bug for calling the class operator
for the archimed class

not certain if it has to do with registration or
bad name in menu to call it

thanks
happy bl

You need class.bl_idname, not bl_idname.bl_idname.

layout.operator(Archimedean_spiral1.bl_idname, icon='MESH_CUBE')

or

layout.operator("OBJECT_PT_helo1", icon='MESH_CUBE')

and do you need to register unregister this class too ?

I already tried with “OBJECT_PT_helo1” and did not work
could not see the name in the menu

will try again
I get error

rna_uiItemO: operator missing srna ‘OBJECT_PT_helo1’

thanks
happy bl

Try this

import bpy


class MENU_MT_MyCustom(bpy.types.Menu):      
    bl_label = "Parabola1"     
    bl_idname = "MENU_MT_my_custom_menu"
        
    def draw(self, context):
        layout = self.layout                             
        layout.operator(OBJECT_OT_Archimedean_spiral1.bl_idname, icon='MESH_CUBE')
           
        
def MyCustomMenuAdd(self, context):
    self.layout.menu(MENU_MT_MyCustom.bl_idname, icon='PLUGIN')


class OBJECT_OT_Archimedean_spiral1(bpy.types.Operator):
    """Add Archimedean Spiral"""
    bl_label = "Archimedean Spiral"
    bl_idname = "object.archimedean_spiral1"
    bl_options = {'REGISTER', 'UNDO'}


    seg1 : bpy.props.IntProperty(name="Segments", description="Number  segments", default=16, min=4, max=100)
    nturn : bpy.props.FloatProperty(name="nturn", description="nturn",default=2.5, min=0.1, max=100.0)
    ht : bpy.props.FloatProperty(name="Height/turn",description="Height/turn", default=0.0, min=0.0, max=100.0)
    a1 : bpy.props.FloatProperty(name="a1",description="a1",default=0.1, min=0.001, max=100.0)

                
    def execute(self, context):
        print("Add my operator code here")
        return {'FINISHED'}


classes = (
    MENU_MT_MyCustom,
    OBJECT_OT_Archimedean_spiral1,
)


def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)    

    bpy.types.VIEW3D_MT_mesh_add.append(MyCustomMenuAdd)


def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
        
    bpy.types.VIEW3D_MT_mesh_add.remove(MyCustomMenuAdd)

    
if __name__ == "__main__":
    register()

It seems to register fine.