Prepping addons for 2.8

I’m working to get my addon ready for 2.8, so I did some work back in December, but I noticed that not all of the proposed python API changes had been pushed to the version of 2.8 I got from the main blender downloads page and the changes I made quickly broke.

Where should I be looking for updated information about this, and should I be getting code from a specific branch perhaps? Need some guidance here. I don’t have a ton of experience with maniphest yet so a pointer or two there might be great also…

Here are the links I know about, which describe things I need to do to get my addons ready for 2.8:
https://wiki.blender.org/index.php/Dev:2.8/Source/LayersCollections/API-Changes
https://wiki.blender.org/index.php/Dev:2.8/Source/Python/UpdatingScripts
https://developer.blender.org/T47811
https://developer.blender.org/T52599

What am I missing? @ideasman42 ?

Thanks!

2 Likes

It’s too early. The first beta for Blender 2.8 is slated for Q3, the code quest hasn’t even begun yet either.

Still, is there a branch or something where the python API changes are slated to be pushed? I am not hugely concerned about doing work and having to throw some of it away (if there are partial changes somewhere I can start working off of that, I would like to get Mesh Align Plus working early…).

Edit: It seems that I should just wait for changes to the official 2.8 repo. I’ll do that unless someone has any better info to offer…

The python API changes according with C/C++ code changes. As 2.8 is still in pre-alpha mode, the API can change a lot, so it’s better wait.

2 Likes

The main change so far is object access, instead of objects being linked to scenes, they’re linked to collections, which are stored in view-layers.

You can access this in Python already, but I think we should make some good examples of how we recommend import/exporters manage objects. We might even have a wrapper function for this if it proves to be too involved for quickly adding objects to the current context.

Other changes to rendering will probably need updating too - if your add-ons access materials for eg.

As far as i can tell,

Selecting object make it active by default, this is a major change - temporary ?.
API changes refers to context.render_layer wich still dosen’t exists ?

How to set the active object? Scene.objects.active = ob doesn’t work anymore.

Inspired by the Spring team, I’d like to switch to 2.8 already:)

Blender 2.8 did not even allow me to import PIL for my addon, last time I tried. Meaning I cannot even make my addon load.

Mind you , I did not expect it to work.

Thus its suffice to say is too early to prepare for addons, its not as if in 3 months we will have a stable Blender 2.8 release anyway. It will take probably a year , at least that is my assumption and estimation by looking at the state of the code in the blender 2.8 branch and the roadmap.

To make things worse, the Blender Python API is the last thing to deal with because having a stable executable code is far more important. This is normal cause the Python API is highly dependent on the existing C/C++ code base and without it , it cannot work. Much of the Blender Python API is not even written in Python.

That’s okay, I’m ready to change the script over and over.

Given that the Spring team already uses 2.8, I assume there must be a way for setting the active object. I tried to look it up in the source but it’s quite too large for fulltext search.

EDIT: Cool! I found it on the wiki page ‘API Changes’ (with a bit of guesswork). We can do context.view_layer.objects.active = ob

1 Like

Do you know how to select a object?

Our addon is working quite nicely in Blender 2.8 alpha 2. No real issues to speak of, but there are a butt load of warnings on startup which make me nervous of impending changes. Can anyone shed light on what they are regarding?

Warning: class CROWDRENDER_OT_connect_remote_server contains a properties which should be a field!
/Users/jamescrowther/Library/Application Support/Blender/2.80/scripts/addons/crowdrender/src/cr/ui_operators.py:4125
    make field: CROWDRENDER_OT_connect_remote_server.node_name

I can’t find anything on what a field is and why it should replace a property. Blender 2.8 alpha seems to still use properties, there are no ‘fields’ in the bpy module as far as I can tell.

Would be nice to know why these warnings are happening and how to silence them as there are a lot of them, they warn me for every blender property I have used in the addon code.

1 Like

It refers to this:
https://wiki.blender.org/wiki/Process/Addons/Guidelines/UpdatingScripts#Class_Property_Registration

Is the term “field” something some Blender dev made up or is it really called that way in Python?
I’m trying to find an official source for this word.

1 Like

They’re (type) annotations:

Not sure why they are referred to as fields. @ideasman42, should we rename this?

1 Like

Yes that’s what I thought as well. Just found it very confusing. Personally I think we should not use the word “field”.

I know the original planning was for addon devs to update September 19, but then the beta was delayed. Is it still advisable to wait, or are py API changes pretty well solidified at this point?

Related question: I’m trying to update my addon based on changes listed on the wiki (original post links)…what’s the best way for me to get diagnostic/warning messages upon loading my addon, should I launch via terminal and check there?

I also agree with jacqueslucke, using the term “fields” for the new property registration system that uses type annotations is confusing (it should at least be well explained in the wiki that it’s a standard python feature, and not some extra package like the “fields” package on pypi if that’s the case).

@AFWS You can select an object with your_object.select_set(action=‘SELECT’) in current code.

btw: The term “field” is getting replaced in the source code now. https://developer.blender.org/rBe228574417e66436c682e120c916bd21f292feda

1 Like

It’s not quite solid at this point yet. We are also lacking documentation of how to do typical operations with the API, and it’s most efficient for us to test and document those first instead of dealing with questions and bugs one by one.

At the moment we are aiming to have it more stable by the beta, at the end of October.

For Python errors and warnings you should indeed look in the terminal.

Another day another build another broken addon, this time bpy.app.autoexec_fail is gone in 2.80.31. This has of course broken our addon and so I am trying to figure out where bpy.app.autoexec_fail has moved to or if its been deprecated entirely.

Any help would be greatly appreciated. Also 2.80.31 has introduced an interesting bug where the UI only covers 2/3 of the window and the visible mouse pointer location doesn’t match where Blender thinks the pointer actually is. Screenshot uploaded:

I am running MacOs Mojave 10.14.1 on a 2015 macbook pro intel i5 chip, 8GB RAM. Do any of the devs want this to be a bug report? happy to provide more info if you do.

bpy.app.autoexec_fail was removed because the code to warn about auto execution of scripts was moved to C. It was never really intended for addons to use, what did you need it for? We could add it back if there’s a good reason

We already have a report in the tracker about that macOS screen scaling issue

1 Like