# ----------------------------------------------------------
# Lamp DATA copier
# (c) 2004 jean-michel soler
# -----------------------------------------------------------
import Blender
from Blender import *
from Blender.Draw import *
from Blender.BGL import *
O = Object.GetSelected()
def renew():
global O
MAJ='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
O = Object.GetSelected()
param= [ p for p in dir(O[0].getData()) if
(p.find('set')!=0 and p.find('get')!=0 and (MAJ.find(p[0])==-1 or (p in
['R','G','B']))) ]
PARAM={}
evt=4
for p in param:
PARAM[p]=[Create(0),evt]
evt+=1
return PARAM
def copy():
global PARAM
OBJECT=None
TYPE=None
for O in Blender.Object.GetSelected():
if O.getType()!='Mesh' and O.getType()!='Empty'
:
if OBJECT==None
and TYPE==None:
OBJECT=O.getData()
TYPE= O.getType()
elif O.getType()==TYPE:
for p in PARAM.keys():
if PARAM[p][0].val==1:
try:
exec "O.getData().%s=OBJECT.%s"%(p,p)
except:
print "La copie de ", p, " n\'est pas possible pour le type d\'objet :
", TYPE
PARAM= renew()
def EVENT(evt,val):
pass
def BUTTON(evt):
global PARAM
if (evt==1):
Exit()
if (evt==2):
copy()
Blender.Redraw()
if (evt==3):
PARAM= renew()
Blender.Redraw()
def DRAW():
global PARAM, O
glColor3f(0.7, 0.7, 0.7)
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(0.1, 0.1, 0.15)
size=Buffer(GL_FLOAT, 4)
glGetFloatv(GL_SCISSOR_BOX, size)
size= size.list
for s in [0,1,2,3]: size[s]=int(size[s])
ligne=20
Button ("Exit",1,20,4,80,ligne)
Button ("Copy",2,102,4,80,ligne)
Button ("renew",3,184,4,80,ligne)
glRasterPos2f(20, ligne*2-8)
Text(O[0].getType()+" DATA copier")
max=size[3] / 22 -2
pos = 1
decal = 20
for p in PARAM.keys():
if pos==max:
decal+=102
pos=1
else:
pos+=1
PARAM[p][0]=Toggle(p,PARAM[p][1],decal,pos*22+22,100,20,
PARAM[p][0].val)
Register(DRAW,EVENT,BUTTON) |