3
""" Registration info for Blender menus: <- these words are ignored
7
Tip: 'Copy data from active object to other selected ones.'
10
__author__ = "Jean-Michel Soler (jms), Campbell Barton (Ideasman42)"
11
__url__ = ("blender", "blenderartists.org",
12
"Script's homepage, http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_lampdatacopier.htm",
13
"Communicate problems and errors, http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender")
17
Use "Data Copier" to copy attributes from the active object to other selected ones of
20
This script is still in an early version but is already useful for copying
21
attributes for some types of objects like lamps and cameras.
25
Select the objects that will be updated, select the object whose data will
26
be copied (they must all be of the same type, of course), then run this script.
27
Toggle the buttons representing the attributes to be copied and press "Copy".
30
# ----------------------------------------------------------
31
# Object DATA copier 0.1.2
32
# (c) 2004 jean-michel soler
33
# -----------------------------------------------------------
34
#----------------------------------------------
35
# Page officielle/official page du blender python Object DATA copier:
36
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_lampdatacopier.htm
37
# Communiquer les problemes et erreurs sur:
38
# To Communicate problems and errors on:
39
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
40
#---------------------------------------------
41
# Blender Artistic License
42
# http://download.blender.org/documentation/html/x21254.html
43
#---------------------------------------------
47
from Blender.Draw import *
48
from Blender.BGL import *
51
scn= Blender.Scene.GetCurrent()
53
type_func_method= type(dir)
54
type_func= type(lambda:i)
58
IGNORE_VARS = 'users', 'fakeUser', 'edges', 'faces', 'verts', 'elements'
61
scn= Blender.Scene.GetCurrent()
62
act_ob= scn.objects.active
66
act_ob_type= act_ob.getType()
67
act_ob_data= act_ob.getData(mesh=1)
69
if act_ob_data==None: # Surf?
76
for prop_name in dir(act_ob_data):
77
if not prop_name.startswith('__') and prop_name not in IGNORE_VARS:
79
try: exec 'prop_type= type(act_ob_data.%s)' % prop_name
80
except: prop_type= None
82
if prop_type != None and prop_type not in (type_func_method, type_func, type_dict):
84
# Now we know that the attribute can be listed in the UI Create a button and tooltip.
90
exec "doc=str(%s.Modes)+' ; value : %s'"%( act_ob_type, str(act_ob_data.mode) )
92
exec """doc= '%s'+' value = '+ str(act_ob.getData(mesh=1).%s)"""%(prop_name, prop_name)
93
elif prop_name=='type':
95
exec "doc=str(%s.Types)+' ; value : %s'"%( act_ob_type, str(act_ob_data.type) )
97
exec """doc= '%s'+' value = '+ str(act_ob.getData(mesh=1).%s)"""%(prop_name, prop_name)
99
exec """doc= '%s'+' value = '+ str(act_ob_data.%s)"""%(prop_name, prop_name)
100
if doc.find('built-in')!=-1:
101
exec """doc= 'This is a function ! Doc = '+ str(act_ob_data.%s.__doc__)"""% prop_name
106
PARAM[prop_name]= [Create(0), evt, doc]
114
scn= Blender.Scene.GetCurrent()
115
act_ob= scn.getActiveObject()
117
Blender.Draw.PupMenu('Error|No Active Object.')
120
act_ob_type= act_ob.getType()
122
if act_ob_type in ('Empty', 'Surf'):
123
Blender.Draw.PupMenu('Error|Copying Empty or Surf object data isnt supported.')
126
act_ob_data= act_ob.getData(mesh=1)
128
print '\n\nStarting copy for object "%s"' % act_ob.name
130
for ob in scn.objects.context:
131
if ob != act_ob and ob.getType() == act_ob_type:
133
for prop_name, value in PARAM.iteritems():
136
# Init the object data if we havnt alredy
138
ob_data= ob.getData(mesh=1)
141
exec "ob_data.%s = act_ob_data.%s"%(prop_name, prop_name)
144
print 'Cant copy property "%s" for type "%s"' % (prop_name, act_ob_type)
146
Blender.Draw.PupMenu('Some attributes could not be copied, see console for details.')
169
scn= Blender.Scene.GetCurrent()
170
act_ob= scn.objects.active
172
glColor3f(0.7, 0.7, 0.7)
173
glClear(GL_COLOR_BUFFER_BIT)
174
glColor3f(0.1, 0.1, 0.15)
176
size=Buffer(GL_FLOAT, 4)
177
glGetFloatv(GL_SCISSOR_BOX, size)
179
for s in [0,1,2,3]: size[s]=int(size[s])
182
Button("Exit",1,20,4,80,ligne)
183
Button("Copy",2,102,4,80,ligne)
184
Button("Renew",3,184,4,80,ligne)
186
glRasterPos2f(20, ligne*2-8)
188
Text(act_ob.getType()+" DATA copier")
190
Text("Please select an object")
205
PARAM[p][0]=Toggle(p,
215
Register(DRAW,EVENT,BUTTON)