1
$\begingroup$

This simple script below does work for blender 2.79 but simply won't show the properties in blender 2.8 (it does draw the panel but it is empty inside)

import bpy


class SomeOtherClass:
    someMember = 100


class MyNewPanel(bpy.types.Panel):
    bl_label = "myNewPanel"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        cubee = bpy.data.objects['Cube']
        somethingElse = SomeOtherClass()
        self.layout.label("Hey there")
        self.layout.prop(cubee, "location")
        self.layout.prop(cubee, "name")
        self.layout.prop(somethingElse, "someMember")

bpy.utils.register_class(MyNewPanel)

Did something change in blender 2.8 which causes it not to work or is it a bug that will be fixed in future? Hence, the second question: if I learn blender api in for 2.79, to what extent can I then use it for 2.8? Also, would it be difficult to bring my add-ons from blender 2.79 to blender 2.8?

$\endgroup$
  • 2
    $\begingroup$ The API for 2.8 is indeed different than the API from 2.79. See changes here. If your addon isn't that complex, updating it for 2.8 will not be very time intensive. $\endgroup$ – Leander Feb 24 '19 at 18:05
  • $\begingroup$ @Leander too bad that I didn't check it myself, thanks! it seems at the first glance that the naming convention for the classes was a problem - it needs the PT suffix in the middle of its name. Now it does work correctly. The console just threw some weird indentation erros at me and there was nothing about the wrong naming $\endgroup$ – Serhii Feb 24 '19 at 18:25
  • $\begingroup$ Sounds great, could you expand on that in answer to this question (the changed names etc) so others can benefit from it as well? $\endgroup$ – Leander Feb 24 '19 at 18:27
1
$\begingroup$

The problem was not with the naming conventions (or at least, that wasn't the only problem, I don't know if Blender does enforce this). I also had 'TABERROR' object has no attribute 'msg' and I didn't have any classes in my script.

I finally found out what the problem was. The file failed to parse (hence no line number information) because there was an invisible error in the indentation. In particular, some lines were indented with tabs, others with spaces. In my case this was caused by me using tabs for indentation in my own editor, then editing the script in Blender's text editor, which automatically inserts spaces instead.

Opening it back up in my text editor and making all indentation consistent fixed the problem.

| improve this answer | |
$\endgroup$
0
$\begingroup$

not 100% sure that was the reason but everything started working when I changed the naming convention for the class. FYI, it was failing in multiple ways before: - first, it was throwing the indentation error, although I've checked indentation multiple times for correctness {'TABERROR' object has no attribute 'msg'}; - second, it failed to draw the contents of the panel with no error;

change the name of the class in accordance with the new standard: it should contain the 'PT' suffix for the panel and in general satisfy the following regular expression: [A-Z0-9_]+PT[A-Za-z0-9_]+ that is, capital first letters (digits and underscores as well), underscore, literal "PT", small/capital letters/ underscores/ digits. The code started working fine with no errors after the ammendments

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.