- 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
myCurveData = Blender.Object.Get(myCurve) # Get data of curve
myCurveName = Blender.Curve.Get()[0] # Assign myCurveName string as the name of the object
myCurvePoints = n = 0
myPathLength = myCurveName.getPathLen()
myCurvedName = myCurveName.getName()
myCurveIPO = Blender.Ipo.New('Object', 'myCurve') # Attmpting to get the Curve name same as IPO curve set
myCurveData = myCurve.data
myCurvePoints = myCurveData.__getitem__(myCurvePoints)
handleTypes= (Blender.BezTriple.HandleTypes.FREE, Blender.BezTriple.HandleTypes.FREE)
print "\n##############################################\n"
print "Curve is: %s \n" % myCurve
print "Curve name: %s \n" % myCurveName
print "Ipo curves: %s \n" % myCurveIPO
print "Ipo length: %s \n" % myPathLength
print "##############################################\n"
H1x = myCurvePoints
H1y = myCurvePoints
H1z = myCurvePoints
Px = myCurvePoints
Py = myCurvePoints
Pz = myCurvePoints
H2x = myCurvePoints
H2y = myCurvePoints
H2z = myCurvePoints
for nCurvePoints in 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 \n" % nCurvePoints
print"H1x: %s \n" % H1x
print"H1y: %s \n" % H1y
print"H1z: %s \n" % H1z
print"\n"
print"Px: %s \n" % Px
print"Py: %s \n" % Py
print"Pz: %s \n" % Pz
print"\n"
print"H2x: %s \n" % H2x
print"H2y: %s \n" % H2y
print"H2z: %s \n" % H2z
print"##############################################\n"
scn = Scene.GetCurrent()
Blender.Curve.data.getFlag(3) == true # Is "CurvePath" flag set.
bit 3 is the flag that I assume looks at the button in the editing buttons "F9", "Curve and Surface" -> "CurvePath"
Shouldn't show the exception
Blender.Draw.PupMenu("Curve is not a Path")
But my biggest problem is that I can't figure out how to allocate each number in the matrix of BezTriple into a seperate variable, which I can print out on screen