# Access operator's property with python

Is it possible to access the property of an operator (such as the filepath to the append operator) by python ?

• Can you elaborate? – batFINGER Aug 6 '16 at 16:36
• – zeffii Aug 6 '16 at 21:37
• Possible duplicate of Return values of operators – p2or Aug 7 '16 at 12:03
• poor this is not a duplicate of that Question, it's not about the return values but about the values that can be passed to the operator. – zeffii Aug 20 '16 at 11:34

Passing properties to an operator, here's a small example (see the test call towards the end). This snippet is an elaboration on TextEditor > Templates > Python > Operator Simple

import bpy

class SomeOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.some_operator"
bl_label = "Simple Object Operator"

property_one = bpy.props.StringProperty(default='state one')
property_two = bpy.props.StringProperty(default='state two')

@classmethod
def poll(cls, context):
return True

def execute(self, context):
print(self.property_one)
print(self.property_two)
return {'FINISHED'}

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

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

if __name__ == "__main__":
register()

# test call
bpy.ops.object.some_operator(property_one='woop_one', property_two='woop_two')


if you want to call such an operator from a layout element..

# if you want to pass a single property
row.operator('object.some_operator').property_one = 'some_new_value'

# if you want to pass multiple properties
some_op = row.operator('object.some_operator')
some_op.property_one = 'some new value one'
some_op.property_two = 'some new value two'


### Autocomplete

If you don't know the name of the properties, then you can use the Python console's autocomplete.

In this example hit ctrl+space after the parenthesis ( , here you see lines is the only property you can set.

### Documentation

Another resource is the current api docs use the search feature, type in for example bpy.ops.text.scroll and it will show the signature.

In the case of WM_OT_append you should be looking for bpy.ops.wm.append.

### Tooltips

Use the tooltip that appears by default upon hovering of menu items / buttons:

• Thank you for your reply but i'd like doing the same operation but with operators which i don't know name of the properties as the WM_OT_append operator. – pistiwique Aug 6 '16 at 20:17
• @pistiwique how did you find the name of WM_OT_append ? – zeffii Aug 20 '16 at 11:36
• By using the console's autocomplete typing bpy.types. – pistiwique Aug 20 '16 at 12:48
• OK, then might I suggest using the tooltips that appear when hovering over menu items, that way you'll see the bpy.ops.* , when you autocomplete those , you will see the parameters as described above – zeffii Aug 20 '16 at 13:31