JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
545 stars 74 forks source link

Auto Load template needs some explanation #76

Closed MochaMoth closed 3 years ago

MochaMoth commented 3 years ago

I don't have a lot of knowledge of python, however some googling made me believe that the auto_load.py file was finding the sub modules in the directory and automatically loading them into blender for the addon. So logically, I took the basic tutorial found Here to move each object in the scene a bit and made a new file with the functional parts of the code. Alas, a log states that the file is not a module is_package = False. I've been googling around more, however I can't seem to find how to tell pkgutil that the file is actually a module. What exactly am I missing?

EDIT - It seems I slightly misunderstood what was happening and the module is being loaded, or at least it's claiming it has been. I added register() and unregister() to the module, however when i call bpy.utils.register_class(ObjectMoveX) I get an error stating already registered as a subclass. So instead, i just log Loading ObjectMoveX which does print, but the command does not show up in the command menu.

ObjectMoveX.py

import bpy as blenderpy

class ObjectMoveX(blenderpy.types.Operator):
    """My Object Moving Script"""
    bl_idname = "object.move_x"
    bl_label = "Move X by One"
    bl_options = {"REGISTER", "UNDO"}

    def execute(self, context):
        scene = context.scene
        for obj in scene.objects:
            obj.location.x += 1.0

        return {"FINISHED"}

def register():
    print("Loading ObjectMoveX")
    #blenderpy.utils.register_class(ObjectMoveX)

def unregister():
    print("Unloading ObjectMoveX")
    #blenderpy.utils.unregister_class(ObjectMoveX)
Got GET: {'type': 'ping'}
127.0.0.1 - - [24/Sep/2020 15:55:05] "GET / HTTP/1.1" 200 -
Got POST: {'type': 'reload', 'names': ['CharacterFrame']}
127.0.0.1 - - [24/Sep/2020 15:55:06] "POST / HTTP/1.1" 200 -
Unloading ObjectMoveX
Loading ObjectMoveX
Sending: {'type': 'addonUpdated'}

image