I'm updating my addon to 2.80 and I'm stuck with the new register class system. I try to follow the answer here but I'm not good enough as a coder to understand the solution.
The problem comes to register my group properties of my UI panel, here is my code:
import bpy
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
PointerProperty
)
from bpy.types import (Panel,
Operator,
PropertyGroup
)
class MySettings(PropertyGroup):
path : StringProperty(
name="path",
description="Path to Directory",
default="",
maxlen=1024,
subtype='DIR_PATH')
conform_threshold : FloatProperty(
name="conform_threshold",
description="A float property",
default=0.1,
min=-5,
max=30.0)
invert : BoolProperty(
name="Enable or Disable",
description="A simple bool property",
default = False)
class UI_PT_LynchonPanel(bpy.types.Panel):
"""Las super herramientas de Juan"""
bl_label = "Lynchon Tools"
bl_space_type = 'VIEW_3D'
bl_region_type = "UI"
bl_category = "Lynchon Tools"
def draw(self, context):
####################Y UP##################################
layout = self.layout
row = layout.row()
row.operator("object.y_up")
# Create two columns, by using a split layout.####################MET COMPILER##################################
split = layout.split()
# First column
col = split.column()
col.operator("texture.metal_compiler")
scn = context.scene
mytool = scn.my_tool
col = split.column(align=True)
col.prop(mytool, 'invert' ,text = "Invert")
# Create two columns, by using a split layout. ####################LOW POLY VENUE##################################
split = layout.split()
# First column
col = split.column()
col.label(text="Import Venue")
col.operator( "xml.lowpolygeneratorparticles")
# Second column, aligned
col = split.column(align=True)
col.label(text="Conform Venue")
col.operator( "xml.conform_lp_venue")
# root for export
scn = context.scene
mytool = scn.my_tool
col = layout.column(align=True)
col.prop(mytool, "path", text="")
# Create two columns, by using a split layout. ####################CONFORM HEIGHT##################################
split = layout.split()
# First column
col = split.column()
col.operator("xml.conformheight")
# Second column, aligned
scn = context.scene
mytool = scn.my_tool
col = split.column(align=True)
col.prop(mytool, "conform_threshold")
def register():
bpy.utils.register_class(UI_PT_LynchonPanel)
bpy.utils.register_class(MySettings)
bpy.types.Scene.my_tool = PointerProperty(type=MySettings)
def unregister():
bpy.utils.unregister_class(UI_PT_LynchonPanel)
bpy.utils.unregister_class(MySettings)
del bpy.types.Scene.my_tool
And the error I'm getting back is this one:
location: <unknown location>:-1
Traceback (most recent call last):
File "C:\Users\Juan\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\Lynchon_tools280\UI.py", line 63, in draw
mytool = scn.my_tool
AttributeError: 'Scene' object has no attribute 'my_tool'
and if I'm not wrong the problem has to do with a register the classes, isn't it?
EDIT
Here my init file which registers all my scrits:
import bpy
from . UI import UI_PT_LynchonPanel, MySettings
from . xml_parse_conformHeight import XML_OT_conformheight
from . xml_parse_particles import XML_OT_conformLpVenue, XML_OT_lowPolyGeneratorParticles
from . y_up import LynchOperator
from . metal_compiler import metal_compiler
classes = (UI_PT_LynchonPanel, MySettings, XML_OT_conformheight, XML_OT_conformLpVenue, XML_OT_lowPolyGeneratorParticles, LynchOperator, metal_compiler)
register, unregister = bpy.utils.register_classes_factory(classes)

register()at all, that's the problem – HikariTW May 16 '19 at 12:18bpy.ops.script.reload()to update changed addons. (this had the shortcut F8 in 2.7x and before). Or restart blender. Adding the main thread if at bottom is standard and good practice since it will register the addon in text editor. Quite often not so useful in an__init__.pywhere relative imports will fail. – batFINGER May 16 '19 at 12:35from . import UIand in__init__.pyregister method callUI.register()otherwise your custom property will not be registered. (hence the issue) – batFINGER May 16 '19 at 12:46C:\Users\Juan\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\Lynchon_tools280\UI.py:83 rna_uiItemO: operator missing srna 'object.y_up'– Juan Manuel Lynch May 16 '19 at 12:51bpy.ops.object.y_up()could not be found in py console. Not Registered.... Put a register method in your y_up module and do same. – batFINGER May 16 '19 at 12:59classes = (LynchOperator,) register, unregister = bpy.utils.register_classes_factory(classes)I thius case LynchOperator is the class whith "object.y_up" idname – Juan Manuel Lynch May 16 '19 at 13:02