Meta Tube edit mode vs object mode scaling

When I use the scale handles to scale a Meta tube in object mode the object’s mesh is scaled and the round ends of the tube get stretched out. When the scaling is carried out in edit mode new faces are added to the Meta tube as I scale the object.

How can I access this sort of edit mode scaling by using a Python script? Using object.setSize( x,y,z ) is not the way to go.

I just started using Blender today because I wanted to import lines generated by a script in Rhino and add Meta Tubes around these lines in Blender.

It seems that using the api functions it’s only possible to add Meta Balls and not tubes. I thought I would just draw a tube in the viewport and then a Python script can translate, rotate and scale a copy of that Meta tube so that it fits around each line.

Thanks in advance

You’ll want to have a look at the metaelem class ( http://www.blender.org/documentation/248PythonDoc/Metaball.Metaelem-class.html )

Modifying radius is equivalent to scaling in edit mode. Change Type for metatube/cube/whatever.

Martin

Thanks Martin! Now my script works. This is my second day of Blender and Python so maybe some things could have been done in a more clever in the script. Isn’t there any Method to find the start and end points of a curve? Now I used the following trick which seems to work in my case.

startPoint = curvedata.getControlPoint(0, 0)
end Point = curvedata.getControlPoint(0, 1)

my script that “pipes” lines with Meta Tubes


import Blender
from Blender import Curve, Object, Scene, Metaball

#metaball stuff
res = 0.1
threshold = 0.001

bball = Blender.Object.New("Mball","mb")
metab = Blender.Metaball.New()

sc = Blender.Scene.getCurrent()
lines = Object.GetSelected()

for line in lines:

  curvedata = line.getData()

  p0 = curvedata.getControlPoint(0, 0)
  p1 = curvedata.getControlPoint(0, 1)

  startPoint = Blender.Mathutils.Vector( p0[3], p0[4], p0[5] )
  endPoint = Blender.Mathutils.Vector( p1[3], p1[4], p1[5] )

  vector = endPoint - startPoint
  print vector.length
  midPoint = [ (startPoint[0] + endPoint[0]) /2 , (startPoint[1] + endPoint[1]) /2, (startPoint[2] + endPoint[2]) /2 ]
  
  print "midPoint"
  print midPoint 
  
  #toTrackQuat(track,up)
  quat = vector.toTrackQuat("x","z")

  metaEl = metab.elements.add()
  metaEl.co = Blender.Mathutils.Vector( midPoint )
  #limitation! Length between 0 and 20 on all axes
  metaEl.dims = Blender.Mathutils.Vector( vector.length/2 ,1,1 )  
  metaEl.quat = quat 
  
  metaEl.type = Metaball.Types.TUBE  
  metaEl.radius = 1
  

# set threshold
metab.thresh = threshold
#link
bball.link(metab)
sc.link(bball)
                
#display modification
Blender.Window.RedrawAll()

Markus Wikar