3
$\begingroup$

When calling an operator like wm.link, is there a way to get the user input like selected directory, filepath or object name?

Here is a simple code example:

import bpy

class appendObjectsPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Replace Object"
    bl_idname = "OBJECT_PT_append"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        obj = context.object

        row = layout.row()
        property = row.operator("wm.link")
        property.relative_path=True
        property.autoselect=True
        property.active_layer=True
        property.instance_groups=True        

# ------------------------------------------------------------------------
# register and unregister functions
# ------------------------------------------------------------------------

def register():
    bpy.utils.register_class(appendObjectsPanel)


def unregister():
    bpy.utils.unregister_class(appendObjectsPanel)


if __name__ == "__main__":
    register()
$\endgroup$

1 Answer 1

4
$\begingroup$

Quoting from the API documentation

Operators don’t have return values as you might expect, instead they return a set() which is made up of: {‘RUNNING_MODAL’, ‘CANCELLED’, ‘FINISHED’, ‘PASS_THROUGH’}. Common return values are {‘FINISHED’} and {‘CANCELLED’}.

You might get the arguments passed to a registered operator like this:

bpy.context.active_operator.properties['keyword']

or

bpy.context.window_manager.operators[-1].properties['keyword']

For more information about linking see also BlendDataLibraries and Library.

$\endgroup$
1
  • 1
    $\begingroup$ wm.link doesn't appear in the info area so it is not being registered. I don't think it is possible. $\endgroup$ Nov 15, 2014 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .