Addon dev - how to dev and run in the editor instead of re-installing it every time?

Hi,

I followed the tutorial but everything is in one file so I separated my operators/panel/init… but

  • what development cycle do you guys have ?
  • how can I still run it from the editor without re-installing the addon every time ?

I am talking dev cycle

  • edit
  • package
  • uninstall
  • reinstall
  • test

I try to make it as easy as running my addon in the editor, but

  • I cannot use context.preferences.addons
  • I had to add my project folder to sys.path or my modules could not be imported
  • I have to use these lines otherwise I get an error like my class is already registered
    if hasattr(bpy.types, "someclass"):
        unregister()

thanks

Add this end of your code and run on the Blender’s Text panel:

if __name__ == "__main__":
  register()

that’s not what I asked (and I already have these lines)

I am talking dev cycle

  • edit
  • package
  • uninstall
  • reinstall
  • test

I try to make it as easy as running my addon in the editor, but

  • I cannot use context.preferences.addons
  • I had to add my project folder to sys.path or my modules could not be imported
  • I have to use these lines otherwise I get an error like my class is already registered
    if hasattr(bpy.types, "someclass"):
        unregister()

Then why you ask?

how can I still run it from the editor without re-installing the addon every time ?

This is answer this question.

read above, I am talking DEV CYCLES

running the addon in the editor seems not the way to go, I have many issues

Then you must check your code. Problem is there. Because this line run this code from editor.

If you want unregister each time, then first call “unregister()”, after call “register()”.

Example:

  # Register Message Box to the system...
  try:
    bpy.utils.unregister_class( Vshade_MsgBox )
  except:
    pass
  
  Vshade_MsgBox.bl_label = title
  bpy.utils.register_class( Vshade_MsgBox )
  • I have done similar
  • it still does not solve the other problems

you obviously dont read what I posted

[admin, I edited my question to avoid confusion

can you clean up this mess so I get a chance of someone actually reading my post and answer my question ?

thanks]

I wrote, problem is in your code. We can not know your code.

This is answer of your ask.

You are not know what to doing, real problem is this, and you don’t like true answer.

Good luck and good bye.

thanks for the mess

Honestly IMO the easiest is to use Visual Studio Code and install the blender dev tool by Jacques Lucke. It automatically creates symlinks between the blender addon and your dev folder, reloads the addons file automatically and can be used with autocomplete with a bit of setup.

Here’s a comprehensive step-by-step https://b3d.interplanety.org/en/using-microsoft-visual-studio-code-as-external-ide-for-writing-blender-scripts-add-ons/

I never tested it but you can alternatively take a look at the reboot addon Reboot Blender Addon

1 Like

finaly :slight_smile: someone who can read, lol

I wanted to avoid ziping files then manualy reinstally the addon
I just found a tutorial about this

thanks a lot dude !!

Also keep in mind somewhere around Blender 2.9 (I think) the reload scripts option was made available which avoids the necessity of uninstall repackage install.

Untitled

3 Likes

And you can use symlinks without having to unzip / rezip for example on windows use the command line
mklink /d "path/to/addons/youraddon" "path/to/your/dev/folder".

Nice ! They should really make it more obvious, I always forget that the logo is a button ><

yeah, as I am not fan of vscode and the plugin is for blender 2.8, I made a batch file, but symlinks work too

also apparently some code must be added to the addon to have it hot reload without issues

# Check if this add-on is being reloaded
if "bpy" in locals():
    # reloading .py files
    import importlib
    # from . blendzmq_props import ZMQSocketProperties
    # importlib.reload(ZMQSocketProperties)
    # from . blendzmq_panel import BLENDZMQ_PT_zmqConnector
    # importlib.reload(BLENDZMQ_PT_zmqConnector)

    from . import addon_props  # addon_props.py (properties are created here)
    importlib.reload(addon_props)  # does this file need a def register() / def unregister() for the classes inside?
    from . import addon_panel  # addon_panel.py (panel interface classes are created here)
    importlib.reload(addon_panel)
# or if this is the first load of this add-on
else:
    print("importing .py files")
    import bpy
    from . import addon_props
    from . import addon_panel

Yeah, you finally understand problem is in your code, and changed it.

pasting the above code is more productive than parroting a rather vague answer

yet thanks for helping

What I said before?

If you don’t share your code, how we know what is problem?

I said, “problem is in your code”, but you answered absurdly.

I also asked for a workflow

also the script I inspired my code from has no such lines of code

you wanna be right ? just be right

could’nt give less of a s…