Calling Addon from Script

Hey Guys,

Quick question. I created a script which I add to Blender as addon that load on start-up, Now I am writing second script and I want to call this loaded addon in the script. Is it possible ? because my goolge searching skills find this http://blender.stackexchange.com/questions/8673/how-can-i-safely-call-another-addon but it is not working for me …

My start of the code:


class DialogOne(bpy.types.Operator):    bl_idname = "object.DialogOne"
    bl_label = "Dialog Settings"

According to link I shared above I tried bpy.ops.object.DialogOne, and it gives me error only.
And I didn’t find anything else that could help me so far…

What error does it give you? If you are asking this kind of question you probably did not yet discover the pleasure of figuring out what context a particular operator needs. Depending on where the operator is called, from what kind of window or situation, some operators will complain. To figure this out, you should take a look at the “poll” method of DialogOne.

Bayesian: Ok now it don’t give me an error and actually call the function i look into code and figure out that bl_idname is wrong it should be object.dialog_one not DialogOne, anyway my script that i try to call is pop-up menu something like this:


import bpy
from bpy.props import *

class DialogOperator(bpy.types.Operator):
    bl_idname = "object.dialog_operator"
    bl_label = "Test"

    defValue = bpy.context.active_object.scale[1]
          
    
    propertyScale = IntProperty()
   
    def execute(self, context):
        return {'FINISHED'}


    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)


def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()

and when I run it it show up a menu… I add this script to Addon folder and set auto-loading so it will load automatically and when I find it in space-search and run It does exactly the same… but then I have this script: menu that shows in Tool Props Panel with button like this:


class EditSettings(bpy.types.Operator):
    bl_idname = "edit.settings"
    bl_label = "Edit settings"
    
    def execute(self, context):
        print("Yup")
        bpy.ops.object.dialog_operator
        return{'FINISHED'} 

But after clicking button nothing happen… Logically I want to shot up my pop-up menu, and suggested reading or tutorial or help, solution whatever… how to achieve this?
Thanks :slight_smile:

Not sure if this will work, but try putting “bpy.utils.register_class(DialogOperator)” in register().

I don’t understand what you are doing, but you need a () behind bpy.ops.object.dialog_operator , to actually call the function/operator.

i am sorry it was my fault… i totally overlooked one thing and asked stupid question no wonder you dont understand what i want :slight_smile: thanks for help and please delete this thread…

register_module() is way better than registering individual classes.

Why is register_module() better than register_class()? What do they do differently?

register_module() calls register_class() for all defined classes in a single call, whereas you would have to call reigster_class() for every class individually - which is tedious as you add more classes or rename them, and absolutely unnecessary.