title: Blender python script for a primitive blender exporter
body: <p>I am trying to write a very basic export to blender (from primitive shapes) script. I have to draw cylinders, at various angles and positions. I have information of offset position, and dimensions.</p>
  
  <pre><code>import bpy
  import bgl
  from mathutils import *
  from math import *
  
  material = bpy.data.materials.new('red')
  material.diffuse_color = (1.0,0.0,0.0)
  
  
  def draw_cylinder(name,material,radius,depth,location,rotation,offsetPosition,offsetAngle):
  
      bgl.glRotatef(*offsetAngle[:4]) 
      bgl.glTranslatef(*offsetPosition[:3])
  
      bpy.ops.mesh.primitive_cylinder_add(radius=radius, depth=depth, location=location, rotation=rotation)
  
      Cylinder = bpy.context.active_object
      Cylinder.name = name
      Cylinder.active_material = material
  
      bgl.glTranslatef(*[i*-1 for i in offsetPosition[:3]])
      bgl.glRotatef(*[i*-1 for i in offsetAngle[:4]])
  
      return Cylinder
  
  cmpt = draw_cylinder('first',material,radius=1,depth=2,location=(-1,0,0),rotation=(pi/2,0,0),offsetPosition=(10,2,7),offsetAngle=(pi/2,0,1,0))
  </code></pre>
  
  <p>This does not draw the cylinder at (9,2,7) [nor rotated along y axis] where am i terribly wrong? How can i correct this. Much Appreciate your help.</p>
  
  <p>EDIT: Using Blender version 2.60 (python interactive console 3.2.2)
  Output shows the cylinder, at (-1,0,0). I expect/need it to be at (9,2,7) (location+offsetPosition) </p>