I am using Python to import a specific mesh in Blender, mesh that I want to modify after import using some sliders I have defined. So I have the defined the following function for the import:
import bpy, math, bmesh
def addGlasses(context, r):
# import glasses object
bpy.ops.import_scene.obj(filepath="myMesh.obj", axis_forward='-Z', axis_up='Y', filter_glob="*.obj;*.mtl")
# select the imported object so it has a location
ob = bpy.context.selected_objects[0]
return ob
and then I have defined the user interface for the imported object:
#
# User interface
#
from bpy.props import *
class MESH_OT_glasses_add(bpy.types.Operator):
bl_idname = "mesh.glasses_add"
bl_label = "Add glasses"
bl_options = {'REGISTER', 'UNDO'}
radius = FloatProperty(name="First parameter", default=1.0, min=0.01, max=100.0)
location = FloatVectorProperty(name="Location")
rotation = FloatVectorProperty(name="Rotation")
# Note: rotation in radians!
def execute(self, context):
ob = addGlasses(context, self.radius)
ob.location = self.location
ob.rotation_euler = self.rotation
return {'FINISHED'}
So I can move and rotate the object as I wish with the sliders "Location" and "Rotation" but I want also to modify some specific parts of my mesh. Practically, radius is a slider for my mesh that appears when the mesh is imported and I would like to use it's value to stretch some specific vertices for the mesh (I know which ones they are).
Is there a way to do that? Because I can't even select a single vertex after import.