Post #245: Thanks roaoao, don´t worry about the size, they are ok, It was just a little whi

📋 Metadata

  • Author: Leafar
  • Date: 2016-07-30 07:22:22
  • Type: question
  • Quality Score: 6/10
  • Replies (1): post_00246

🏷️ Tags

macro scripting intermediate unsolved

  • Python Scripting
  • Macro Editor

💬 Content

Thanks roaoao, don´t worry about the size, they are ok, It was just a little whim.

I am trying to use just certain parts of Wazou´s PMs via scripts but I don´t get it… I use, this one for example for putting the center of an object in a selected part of one mesh, anyone can help me??:

import bpy, os
from bpy.types import Menu, Header
from bpy.props import IntProperty, FloatProperty, BoolProperty
import bmesh
from mathutils import *
import math
import rna_keymap_ui

Cursor/Origin

Pivot to selection
class PivotToSelection(bpy.types.Operator):
bl_idname = “object.pivot2selection”
bl_label = “Pivot To Selection”
bl_options = {‘REGISTER’, ‘UNDO’}

def execute(self, context):  
    saved_location = bpy.context.scene.cursor_location.copy()
    bpy.ops.view3d.snap_cursor_to_selected()
    bpy.ops.object.mode_set(mode = 'OBJECT')
    bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
    bpy.context.scene.cursor_location = saved_location 
    return {'FINISHED'}

🔗 View on Blender Artists