1
$\begingroup$

I would like to reset the string property in the toolbar every time I hit the "Object" in the Add.

In short, this is the code I'm using:

class primitive_object_add(bpy.types.Operator):
    bl_idname = "mesh.primitive_object_add"
    bl_label = "Add an object"
    bl_options = {'REGISTER', 'UNDO'}
    img_str = StringProperty(name="Image Name (example: name.png)", description="desc here", default="", subtype='FILE_PATH')

    def execute(self, context):
        #code here

def menu_func(self, context):
    self.layout.operator("mesh.primitive_object_add", text="Object", icon='OBJECT_DATA')


def register():
    bpy.utils.register_module(__name__)
    bpy.types.INFO_MT_mesh_add.append(menu_func)

def unregister():
    bpy.utils.unregister_module(__name__)
    bpy.types.INFO_MT_mesh_add.remove(menu_func)

if __name__ == "__main__":
    register()

I've tried using self.img_str = "" However if I'm not fully sure where I could put this in the code to have it run when I press "Object"

enter image description here

$\endgroup$
3
  • $\begingroup$ I think that should be in premitive_minecraft_item_add() where you initiate a call to this operator and pass the arguments ( including this string ) $\endgroup$
    – Chebhou
    May 25, 2015 at 11:37
  • $\begingroup$ This is going to sound like a really noobish questions, but how would I call img_str = "" from that, any chance you could give a quick example? Thanks! $\endgroup$ May 25, 2015 at 12:13
  • $\begingroup$ I meant calling the operator : bpy.ops.mesh.primitive_object_add(img_str = "some string") $\endgroup$
    – Chebhou
    May 25, 2015 at 12:17

0

You must log in to answer this question.

Browse other questions tagged .