I then moved onto trying to create IPO curves with armatures with objects as children of the armatures, but I found that very difficult to do and have now moved onto a different type of animation to test.
Get an object to go around a set path in a set amount of seconds/frames, again this doesn't produce an IPO curve for the plugin to recognize.
So to hopefully get around this limitation of Blender's, i'm having a go at writing a script for blender to convert a curve into an object IPO curve. I can't see why Blender hasn't even got this feature auto magically.
I have an idea of how to do this, and below is my current code
Version now at: 0.6.6
Current code
- Code: Select all
#!BPY
# A script to convert a curve to an IPO curve which can be used by an object to simulate the path it is flying
# Specifically designed to help with GoW_PyPrp plugin
"""
Name: 'Curve2IPO'
Blender: 246
Group: 'Wizards'
Tooltip: 'Make IPO curves from path'
"""
import Blender
try:
scn = Scene.GetCurrent()
Blender.Curve.data.getFlag(3) == true # Is "CurvePath" flag set.
except:
Blender.Draw.PupMenu("Curve is not a Path")
myCurve = Blender.Object.GetSelected()[0] # Assign what is the currently selected curve
#myCurveName = myCurveName.getName()
myCurveName = myCurve.getName()
myCurveBez = Blender.Object.Get(myCurve) # Get data of curve
myCurveData = Blender.Curve.Get()[0]
myIPOCurveSet = myCurve.getName()
myCurvePoints = n = 0
myPathLength = myCurveData.getPathLen()
myPathIter = myCurrentPathLen = myPathLength
#myIPOCurves = myIPOCurves.LOC[x]
myIPOCurveSet = Blender.Ipo.New('Object', myCurveName) # Attmpting to get the Curve name same as IPO curve set
#myIPOCurves = Blender.IpoCurve.New(myIPOCurveSet)
handleTypes = (Blender.BezTriple.HandleTypes.FREE, Blender.BezTriple.HandleTypes.FREE)
myCurveData = myCurve.data
# Old way -> myCurvePoints = myCurveData.__getitem__(myCurvePoints)
myCurvePoints = myCurveData[myCurvePoints]
myNumberOfPoints = 0
for iNumberOfPoints in myCurvePoints:
myNumberOfPoints = myNumberOfPoints + 1
myPathIter = myPathLength / myNumberOfPoints
print "\n##############################################"
print "Curve name: %s " % myCurveName
print "Curve data: %s " % myCurveData
print "Ipo curves: %s " % myIPOCurveSet
print "Ipo length: %s " % myPathLength
print "Path iteration constant: %s" % myPathIter
print "##############################################\n"
# Create LocX, LocY, and LocZ Ipo curves in our new Curve Object
# and store them so we can access them later
myIPOCurveSet_X = myIPOCurveSet.addCurve('dLocX')
myIPOCurveSet_Y = myIPOCurveSet.addCurve('dLocY')
myIPOCurveSet_Z = myIPOCurveSet.addCurve('dLocZ')
myBezPointNumber = 0
for nCurvePoints in myCurvePoints:
myBezPointNumber = myBezPointNumber + 1
myCurrentPathLen = myPathIter * myBezPointNumber
#myIPOCurves = Blender.Ipo.New(Blender.Ipo.OB_LOCX, 'Ipo1a')
# Create an new Ipo Curve of name myIpo and type Object
#myIPOCurves = bpy.data.ipos.new(myCurveName, 'Object')
#print"%s" %s myCurvePoints
# Apparently BezTriple outputs 9 floats for each handle/knot in 3D space
# so print out each float value
print"\n##############################################"
print"Bezier point number: %s" % myBezPointNumber
print"Out of a total: %s" % myNumberOfPoints
print"Current iteration at frame: %s\n" % myCurrentPathLen
print"H1x: %s " % nCurvePoints.vec[0][0]
print"H1y: %s " % nCurvePoints.vec[0][1]
print"H1z: %s " % nCurvePoints.vec[0][2]
print"\n"
print"Px: %s " % nCurvePoints.vec[1][0]
print"Py: %s " % nCurvePoints.vec[1][1]
print"Pz: %s " % nCurvePoints.vec[1][2]
print"\n"
print"H2x: %s " % nCurvePoints.vec[2][0]
print"H2y: %s " % nCurvePoints.vec[2][1]
print"H2z: %s " % nCurvePoints.vec[2][2]
print"##############################################\n"
# Here set the current frame
# myIpo = myCurveIPO.__setitem__ (myCurrentPathLen, nCurvePoints)
# Here Append current frame with BezTriple nCurvePoints
# myIPOCurves = myIPOCurveSet.IpoCurve.
# myIPOCurves = myIPOCurveSet.__setitem__(myCurrentPathLen, nCurvePoints)
#myIPOCurves = Blender.Ipo.addCurve([Blender.Ipo.OB_LOCX]) # retrieves an Ipo object
#ipo.name = 'ipo1' # change the Ipo's name
#icu = ipo[Blender.Ipo.OB_LOCX] # request X Location Ipo curve object
#if icu != None and len(icu.bezierPoints) > 0: # if curve exists and has BezTriple points
# val = icu[2.5] # get the curve's value at time 2.5
# Append to the Ipo curve at location frame, with the value ipoValue_x
# Note that we should pass the append function a tuple or a BezTriple
myIPOCurveSet_X.append((myCurrentPathLen, nCurvePoints.vec[1][0]))
# Similar to above
myIPOCurveSet_Y.append((myCurrentPathLen, nCurvePoints.vec[1][1]))
myIPOCurveSet_Z.append((myCurrentPathLen, nCurvePoints.vec[1][2]))
Edit: removed a statement I made about following a curve, as after reading the code for about the tenth time, the Bezier addition looks like it related to the IPO curve and not path following by bezier
Edit 1: I'll be placing here in the first post updates to the code when improvement is made
Edit 2: Removed the first block of code