3

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()
p2or
  • 15,860
  • 10
  • 83
  • 143

1 Answers1

4

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.

brockmann
  • 12,613
  • 4
  • 50
  • 93
pink vertex
  • 9,896
  • 1
  • 25
  • 44