# How to modify mesh after import in Blender using Python? [duplicate]

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

# 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 *

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")

def execute(self, context):
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.

Set imported object active:

ob = bpy.context.selected_objects[0]
bpy.context.scene.objects.active = ob


Just for the records, I modified my functions like this and now it works:

def addGlasses(context, r, nseg, vstep, nplanes, twist):

# 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]

# select the imported object active
bpy.context.scene.objects.active = ob

# deselect every part of my mesh
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='DESELECT')

# change mode
sel_mode = bpy.context.tool_settings.mesh_select_mode
bpy.context.tool_settings.mesh_select_mode = [True, False, False]
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

# select the vertices I need
mesh = ob.data
mesh.vertices[1].select = True

bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.context.tool_settings.mesh_select_mode = sel_mode

return ob