here copy-all-shapes.py available for dounload

hi every body!

i’m not add a curve in a keyblock of a mesh object (a curve for animation for a especific key = shape)

import Blender
from Blender import *

obj = Blender.getSelected()[0] #select active object
mesh = obj.getData() # get mesh data of object

mykey = mesh.getKey() # get datablock of keyframes information

myIpo = myKey.getIpo() # get Ipo datablock for keys (vertex animation, each blue line is a shape)

consts_in_myIpo = myIpo.curveConsts # give me a list of names (strings) of shapes in Ipo key datablock

curves_in_myIpo = myIpo.getCurve() # give me all curves of animation (name of curve = name of shape) ipoCurve object

how can i ADD a curve into a shape (that not have one yet) ?

this:

Shape Key Ipos are handled differently from other Ipos. The user can rename the curves, so string are used to access them instead of constants. The [Ipo.curveConsts](file:///media/usbdisk/CJD/Python/BPY%20API%20CVS%207-6-2006/BPY%20API/members.iinet.net.au/_cpbarton/ideasman/BPY_API/Ipo.Ipo-class.html#curveConsts) attribute for Shape Key Ipos returns a list of all defined key names.
dont work or i can’t understand it

EDIT:

download from http://claudiojd.googlepages.com/programacion “copy_all_shapes.py”

Hi CJD, may I ask why you need this, is it about initializing the key curves, that is, just creating them with a default value?

Since the name of Key Ipo curves is the key’s name, there are no valid names for addCurve() when it is a Key Ipo, so I can’t add any new curves (“NameError: curve name is not valid”).

Or with

myKey.ipo['Key 5']=(1,0)

I get: “TypeError: creation or deletion of Shape Keys not supported”

From a quick test, I found out I can assign a full Ipo object to the key, like

myKey.ipo = newipo

I can create a new Ipo object with Blender.Ipo.New() of type Key

newipo = Blender.Ipo.New('Key','KeyIpo')

But then again, I can’t add any curves because there are no valid names for them…!

So the only thing I can do is to to copy the Ipo of one object to another object. But that only works because both objects are similar.

thanks toloban!

i need copy shapes from diferent instances of a mesh to a final mesh, it’s rigth, but y like copy animation curves too.

if you copy shape to shape (based on scipt rvk1torvk2 from JMS) create new shape and copy ver location one by one, but can’t create or add new curve to shapes.

sombody have some idea? the API not work? i am an idiot (don’t reply this, please)?

:confused:

you only need

ipo = Blender.Ipo.New(‘Object’,‘ObIpo’)
cu = ipo.addCurve(‘LocX’)

Un Saludo

Edited . . seria algo como


import Blender
from Blender import *

obj = Blender.Object.GetSelected()[0]
myIpo =  obj.getIpo()
cu=None
if myIpo==None:
    myIpo=Ipo.New('Object','coutum_'+obj.name)
    cu=myIpo.addCurve('LocX')
else:
    cu=myIpo.getCurve('LocX')

print cu


thanks RCRuiz! …but i need it for Key Ipo, and don’t work for it.

:smiley:

I use Shape key ipo creation in my Texture Baker script :
http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_mesh3d2uv2d_en.htm#from_absolute_to_relative

That link gives some working solution, thanks.

I guess I am trying to do something similar as CJD, to append keys from morph targets saved as text files to an object using insertKey() and then add curves to the new keys. I am actually trying to copy the drivers, but at least getting the curves saves me some work.

CJD, Under 2.41, you can get the key curves with myIpo.getCurve(X), where X is the index of the shape key, not by name, if there is no curve, getCurve() returns None. I tried but could never guess that! (is that documented anywhere?)

Then you can create a new curve in the key ipo (ipo2) of the second object with ipo2.createCurve(‘Key X’) (regardless of how the key is named), and then add the nodes.

thanks RCRuiz, jms, toloban.

my investigation :smiley: show me what IPO.addCurve() dont work on “Key” ipo blocks

i post in bug tracker this.

[FONT=verdana][SIZE=1][SIZE=1]http://h1.ripway.com/CJD/blends/BUG_KEY_CURVE_27-6.blend if delete or comment line 37 script work but no add curves

the bug its same for texture baker (jms script), addCurve work in 2.41 but not in after versions :frowning:

thanks again, and i write every news here.

Claudio Dobniewski
[/SIZE][/SIZE][/FONT]

In the same way and the same problem, it seems that the Shape Widget Wizard returns the same error with the Blender 2.42 RC 1 or 2 .

I recovered the python/api_2x/ipo.c made just after the merging between the official CVS and the Orange projetc CVS :
http://projects.blender.org/viewcvs/viewcvs.cgi/checkout/blender/source/blender/python/api2_2x/Ipo.c?rev=1.49&cvsroot=bf-blender&sortby=date&content-type=text/plain
to make a compilation and the function works correctly .

The bug is also reported on bf-python list :
http://projects.blender.org/pipermail/bf-python/2006-June/004051.html

well, K. Hugges are fixed them.

http://projects.blender.org/tracker/index.php?func=detail&aid=4516&group_id=9&atid=125

IPO.addCurve(“everything”) work if key named “everithing” exists, and (NOTE) name duplicates don’t are possibles now for adding names news. (it’s wight)

bye bye! nothing to wath here…:smiley:

(coming soon i publish copy_all_shapes whith curves and ipo drivers support, and… size aplly factor!)

:confused: the example in the bug report works now,

If i add a few more shapes to the example to = 10 or more shape keys in total it will bomb out after 9 curves are added. Still buggy?

Try to report the problem on the bf-python list :
http://projects.blender.org/mailman/listinfo/bf-python

my feedback :wink:

try it [FONT=verdana][SIZE=1][SIZE=1]http://h1.ripway.com/CJD/Scripts/copy_all_shapes.py

Base button “SI” or “Yes” for copy the first shape (basis shape)

select first destination mesh and last “from” mesh.

FACTOR is a mult size for shapes “copies”, NOTE: if basis shape its’n same “size” with new shapes, add weight modifi size. delete basis shape its a good idea here.

enjoy!
[/SIZE][/SIZE][/FONT]

hi, i’m here.

new version, copy-all-shapes_beta.py

[FONT=verdana][SIZE=1][SIZE=1]http://h1.ripway.com/CJD/Scripts/copy_all_shapes_beta.py[/SIZE][/SIZE][/FONT]

download and try!

it work how rvk1 to rvk2 script, but copy ALL shapes. and new (beatifull and usefull) features.

you can (or not) copy base shape, Curves from animation shapes and/or ipo drivers. and scale size from a shape at copy! (factor)

for feedback write here or mail claudiojd(at)yahoo.com.ar

enjoy.:):stuck_out_tongue:

well, finally i take some time and apply toloban (here and kok in niel) notes, version 1.0 is available :smiley:

more stable, more faster and more untested :wink:

http://h1.ripway.com/CJD/Scripts/copy_all_shapes.py

special tanks for your help and feedback