Post #4712: and My new method is modified the source code ,add two commands to record the lo

📋 Metadata

🏷️ Tags

macro python-scripting advanced solved

  • Macro Editor
  • Python Scripting

💬 Content

and My new method is modified the source code ,add two commands to record the location and rotation values and it works. Thanks for your reply anyway.

class WM_OT_pmi_edit_location(bpy.types.Operator):
    bl_idname = "wm.pmi_edit_location"
    bl_label = ""
    bl_description = "Use selected actions"
    bl_options = {'INTERNAL'}

    pm_item: bpy.props.IntProperty()
    auto: bpy.props.BoolProperty()
    add: bpy.props.BoolProperty()
    new_script: bpy.props.BoolProperty()
    mode: bpy.props.StringProperty(options={'SKIP_SAVE'})
    text: bpy.props.StringProperty(options={'SKIP_SAVE'})
    name: bpy.props.StringProperty(options={'SKIP_SAVE'})

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        Lx = bpy.context.object.location[0];
        Ly = bpy.context.object.location[1];
        Lz = bpy.context.object.location[2];
        T = str(((Lx, Ly, Lz)))
        text = 'C.object.location = Vector' + T + ''
        text = text.strip("\n")

        if len(text) > MAX_STR_LEN:
            message_box(CC.W_PMI_LONG_CMD)

            return {'CANCELLED'}

        _edit_pmi(self, text, event)

        return {'CANCELLED'}

class WM_OT_pmi_edit_rotation(bpy.types.Operator):
    bl_idname = "wm.pmi_edit_rotation"
    bl_label = ""
    bl_description = "Use selected actions"
    bl_options = {'INTERNAL'}

    pm_item: bpy.props.IntProperty()
    auto: bpy.props.BoolProperty()
    add: bpy.props.BoolProperty()
    new_script: bpy.props.BoolProperty()
    mode: bpy.props.StringProperty(options={'SKIP_SAVE'})
    text: bpy.props.StringProperty(options={'SKIP_SAVE'})
    name: bpy.props.StringProperty(options={'SKIP_SAVE'})

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        Rx = bpy.context.object.rotation_euler [0];
        Ry = bpy.context.object.rotation_euler [1];
        Rz = bpy.context.object.rotation_euler [2];
        T = str(((Rx, Ry, Rz)))
        text = 'C.object.rotation_euler = Euler' + T + ''
        text = text.strip("\n")

        if len(text) > MAX_STR_LEN:
            message_box(CC.W_PMI_LONG_CMD)

            return {'CANCELLED'}

        _edit_pmi(self, text, event)

        return {'CANCELLED'}

🔗 View on Blender Artists