3 """ Registration info for Blender menus:
7 Tip: 'Set of object aligning, modifying tools'
12 ##################################################
14 # KLOPUTILES v3.1 para Blender v2.33 #
17 ##################################################
18 # Pulsa Alt+P para ejecutar el script
19 # Improved: use of Mathutils
20 # Feature: actualize objects on ApplyLRS
21 # Improved: Project onto planes
22 # Feature: mover/rotar/escalar objetos al azar
23 # Feature: acercar objs al activo (fijo, abs, rel)
24 # Improved: Fit/Embrace
25 # TODO: subdividir solo aristas seleccionadas (NO FUNCIONA)
28 ##################################################
30 # --------------------------------------------------------------------------
31 # Kloputils by Carlos López (klopez)
32 # --------------------------------------------------------------------------
33 # ***** BEGIN GPL LICENSE BLOCK *****
35 # Copyright (C) 2004: Carlos López, http://klopes.tk
37 # This program is free software; you can redistribute it and/or
38 # modify it under the terms of the GNU General Public License
39 # as published by the Free Software Foundation; either version 2
40 # of the License, or (at your option) any later version.
42 # This program is distributed in the hope that it will be useful,
43 # but WITHOUT ANY WARRANTY; without even the implied warranty of
44 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 # GNU General Public License for more details.
47 # You should have received a copy of the GNU General Public License
48 # along with this program; if not, write to the Free Software Foundation,
49 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51 # ***** END GPL LICENCE BLOCK *****
52 # --------------------------------------------------------------------------
55 from Blender.Mathutils import *
56 from Blender.NMesh import *
57 from Blender.BGL import *
58 from Blender.Draw import *
59 from Blender.sys import *
60 from Blender.Noise import random
64 #path=dirname(progname)
65 #path=[dirname(progname),'.blender','bpydata']
66 path=Blender.Get("datadir")
68 errmsg = "\nNo bpydata/ dir found! It should be in Blender's home dir."
71 sc=Blender.Scene.GetCurrent()
72 MId=Matrix([1,0],[0,1])
76 l=PupMenu('Choose language%t|Espanol%x1|English%x2|Catala%x3')
77 Lang=['Espanol','English','Catala'][l-1]
157 def CreaObjDeMalla(mm,o,nombre):
158 oo=Blender.Object.New('Mesh')
161 oo.LocX,oo.LocY,oo.LocZ=o.LocX,o.LocY,o.LocZ
162 oo.RotX,oo.RotY,oo.RotZ=o.RotX,o.RotY,o.RotZ
163 oo.SizeX,oo.SizeY,oo.SizeZ=o.SizeX,o.SizeY,o.SizeZ
167 def rectang(x,y,l,h,r,g,b):
176 def SituaL(objeto,coord,X):
183 def SituaR(objeto,coord,X):
190 def SituaS(objeto,coord,X):
199 return o.getType()=='Mesh'
203 return MatMultVec(MM,D)
205 def GloVrt((x,y,z),M): # Devuelve (vector) coords globs de v
211 def Extremo(lista,M=MId): # Devuelve extremos y pto medio de lista de vectores
212 o1=GloVrt(lista[0],M)
213 o2=GloVrt(lista[0],M)
219 o1[c]=min(va[c],o1[c])
220 o2[c]=max(va[c],o2[c])
221 return [o1,(o1+o2)/2,o2]
223 def Media(lista): #Media
226 for l in lista: ctr[c]=ctr[c]+l[c]
227 ctr[c]=ctr[c]/len(lista)
236 global pagina, toBuffer
237 glClearColor(0.4,0.2,0.2,0.0)
238 glClear(GL_COLOR_BUFFER_BIT)
240 pagina=Menu(menu0,98,20,370,170,28,pagina.val,"Select page")
241 toBuffer=Menu(menu4,80,200,370,20,15,toBuffer.val,"Copy values to the internal buffer")
242 glColor3f(0.6,0.6,0.2)
243 glRasterPos2i(198,388)
246 if (pagina.val==1): draw1()
247 elif (pagina.val==2): draw2()
248 elif (pagina.val==3): draw3()
249 elif (pagina.val==4): draw4()
251 Button(menuExit,99,20,5,200,18)
255 global aliX,aliY,aliZ,numReal,movekomo,menuLRS,menuPaste
258 rectang(15,38,225,264,0.2,0.,0.)
260 moveke=Menu(menu5,98,10,248,200,20,moveke.val,"Modify the matrices of selected objects")
262 aliX=Toggle("X",0, 50,160,45,30,aliX.val,"Activate modification in X")
263 aliY=Toggle("Y",0, 95,160,45,30,aliY.val,"Activate modification in Y")
264 aliZ=Toggle("Z",0,140,160,45,30,aliZ.val,"Activate modification in Z")
265 menuLRS=Menu("Loc%x1|Rot%x2|Size%x3",98,20,110,50,20,menuLRS.val)
267 movekomo=Menu(menu5a,98,20,225,200,20,movekomo.val,"Transformation type")
268 m,M,tip= -100,100,"Quantity"
271 m,M,tip= -1000, 1000, "Distance"
273 m,M,tip= 0, 360, "Angle"
275 m,M,tip= 0, 100, "Scale"
276 if moveke.val==1 and movekomo.val==3: tip=tip+"Multiplier "
277 if moveke.val==2: tip=tip+" (max)"
279 numReal=Number("",0,20,140,178,18,numReal.val,m,M,tip)
280 glColor3f(0.6,0.6,0.2)
281 glRasterPos2i(200,156)
282 Text("Paste",'small')
283 menuPaste=Menu("Paste...%t|LocX%x1|LocY%x2|LocZ%x3|\Loc\%x4|RotX%x5|RotY%x6|RotZ%x7|SizeX%x8|SizeY%x9|SizeZ%x10"
284 ,88,202,140,20,12,0,"Paste what?")
285 ok=Button("OK",50,80,110,80,20)
289 global editake,ndiv,akeplano,akeplanoXYZ,enkedir,ok
291 global getlocrotsiz,ok,nLocX,nLocY,nLocZ
292 global nRotX,nRotY,nRotZ,nSizX,nSizY,nSizZ
293 global Cloc,Ploc,Crot,Prot,Csiz,Psiz
295 rectang(15,38,225,264,0.3,0.7,0.5)
297 editake=Menu(menu3,98,10,248,143,20,editake.val,"Mesh editing menu")
299 ndiv=Number(menu3a,98,20,200,150,18,ndiv.val,2,1000)
300 ok=Button("OK",20,172,200,32,18)
301 elif(editake.val==2):
302 akeplano=Menu(menu3b,98,20,200,140,20,akeplano.val)
303 if akeplano.val in [1,2]:
304 akeplanoXYZ=Menu(menu3c,98,162,200,55,20,akeplanoXYZ.val)
305 enkedir=Menu(menu3d,98,20,100,140,20,enkedir.val)
306 ok=Button("OK",40,162,100,55,20)
307 elif(editake.val==3):
308 Button("P",87,192,222,30,18,"Paste buffer matrix")
309 nLocX=Number("LocX:",98,20,200,170,19,nLocX.val,-1000.,1000.)
310 nLocY=Number("LocY:",98,20,180,170,19,nLocY.val,-1000.,1000.)
311 nLocZ=Number("LocZ:",98,20,160,170,19,nLocZ.val,-1000.,1000.)
312 nRotX=Number("RotX:",98,20,140,170,19,nRotX.val,-1000.,1000.)
313 nRotY=Number("RotY:",98,20,120,170,19,nRotY.val,-1000.,1000.)
314 nRotZ=Number("RotZ:",98,20,100,170,19,nRotZ.val,-1000.,1000.)
315 nSizX=Number("SizeX:",98,20, 80,170,19,nSizX.val,-1000.,1000.)
316 nSizY=Number("SizeY:",98,20, 60,170,19,nSizY.val,-1000.,1000.)
317 nSizZ=Number("SizeZ:",98,20, 40,170,19,nSizZ.val,-1000.,1000.)
318 other=Toggle("Refresh others",98,20,222,170,18,other.val)
319 oklocrotsiz=Button("OK",30,192,40,30,179)
322 global creake,ang1,ang2,angulo,radio,pts,ctro,meTx,arcorden
324 rectang(15,65,224,257,0.7,0.5,0.65)
326 creake=Menu(menu2,98,10,248,143,20,creake.val,"Object type")
328 pts=Number(menu2a[0],98,20,115,80,18,pts.val,2,1000)
329 ctro=Toggle(menu2a[1],98,102,115,50,18,ctro.val,"Close the arc with a vertex on its center")
330 arcorden=Menu(menu2a[2]+"%t|1-2-3%x1|2-3-1%x2|3-1-2%x3",17,155,115,65,18,arcorden.val,"Vertices order (arc is created when this is chosen)")
331 meTx=String("Object: ",98,20,70,200,22,meTx.val,30,"New object's name")
333 ang1=Slider(menu2a[4],10,20,220,200,18,ang1.val,-360,360,0,"Initial angle in degrees")
334 ang2=Slider(menu2a[5],11,20,200,200,18,ang2.val,ang1.val,ang1.val+360,0,"Final angle in degress")
335 angulo=Slider(menu2a[6],12,20,170,200,18,angulo.val,-360,360,0,"Arc's angle in degress")
336 radio=Slider(menu2a[7],13,20,140,200,18,radio.val,0,1,0)
337 pts=Number(menu2a[8],14,20,115,80,18,pts.val,2,1000)
338 ctro=Toggle(menu2a[9],15,102,115,50,18,ctro.val,"Close the arc with a vertex on its center")
339 meTx=String(menu2a[10],16,20,70,200,22,meTx.val,30,"Name of the mesh to substitute")
341 pts=Number("Pts:",98,20,115,80,18,pts.val,2,1000)
342 ok=Button("OK",18,102,115,120,36)
343 meTx=String("Object: ",98,20,70,200,22,meTx.val,30,"New object's name")
346 global menueqiX,sepX,aliX,menueqiY,sepY,aliY,menueqiZ,sepZ,aliZ
347 global girX,incX,girY,incY,girZ,incZ
348 global encX,encY,encZ,en2X,en2Y,en2Z
349 global scaX,scaY,scaZ,iScaX,iScaY,iScaZ
350 global CreaNew,Cuantos,toBuffer
352 ######################### ALINEACIONES #####################
353 rectang(5,167,254,292,0.7,0.5,0.65)
354 Button("C",81,194,270,25,18,"Copy")
355 Button("P",82,220,270,25,18,"Paste buffer Loc")
357 aliX=Toggle("X",0,10,270,30,18,aliX.val,"Activate X alignment")
358 menueqiX=Menu(menu1b,98,41,270,148,18,menueqiX.val,"Separation extremes")
359 sepX=Number(menu1a[4],0,10,250,179,18,sepX.val,-1000,1000,"X separation distance")
361 aliY=Toggle("Y",0,10,230,30,18,aliY.val,"Activate Y alignment")
362 menueqiY=Menu(menu1b,98,41,230,148,18,menueqiY.val,"Separation extremes")
363 sepY=Number(menu1a[4],0,10,210,179,18,sepY.val,-1000,1000,"Y separation distance")
365 aliZ=Toggle("Z",0,10,190,30,18,aliZ.val,"Activate Z alignment")
366 menueqiZ=Menu(menu1b,98,41,190,148,18,menueqiZ.val,"Separation extremes")
367 sepZ=Number(menu1a[4],0,10,170,179,18,sepZ.val,-1000,1000,"Y separation distance")
369 ########################## GIROS ##############################
370 rectang(5,97,254,162,0.67,0.54,0.1)
371 Button("C",83,194,140,25,18,"Copy")
372 Button("P",84,220,140,25,18,"Paste buffer Rot")
374 girX=Toggle("X",0,10,140,30,18,girX.val,"Increment RotX values")
375 incX=Number("X: ",0,42,140,147,18,incX.val,-180,180,"X increment in degress")
376 girY=Toggle("Y",0,10,120,30,18,girY.val,"Increment RotY values")
377 incY=Number("Y: ",0,42,120,147,18,incY.val,-180,180,"Y increment in degrees")
378 girZ=Toggle("Z",0,10,100,30,18,girZ.val,"Increment RotZ values")
379 incZ=Number("Z: ",0,42,100,147,18,incZ.val,-180,180,"Z increment in degrees")
381 ######################### ESCALADOS ##########################
382 rectang(5,27,254,92,0.27,0.54,0.4)
383 Button("C",85,194,70,25,18,"Copy")
384 Button("P",86,220,70,25,18,"Paste buffer Sca")
386 scaX=Toggle("X",0,10,70,30,18,scaX.val)
387 iScaX=Number(menu1a[7],0,42,70,147,18,iScaX.val,-180,180,"X scale increment")
388 scaY=Toggle("Y",0,10,50,30,18,scaY.val)
389 iScaY=Number(menu1a[7],0,42,50,147,18,iScaY.val,-180,180,"Y scale increment")
390 scaZ=Toggle("Z",0,10,30,30,18,scaZ.val)
391 iScaZ=Number(menu1a[7],0,42,30,147,18,iScaZ.val,-180,180,"Z scale increment")
392 ########################## ENCAJES ##########################
393 rectang(5,317,254,363,0.1,0.5,0.6)
395 encX=Toggle(menu1a[0]+"X",0,10,340,43,18,encX.val,"Move object in X")
396 encY=Toggle(menu1a[0]+"Y",0,55,340,43,18,encY.val,"Move object in Y")
397 encZ=Toggle(menu1a[0]+"Z",0,100,340,43,18,encZ.val,"Move object in Z")
399 en2X=Toggle(menu1a[1]+"X",0,10,320,43,18,en2X.val,"Adjust X size")
400 en2Y=Toggle(menu1a[1]+"Y",0,55,320,43,18,en2Y.val,"Adjust Y size")
401 en2Z=Toggle(menu1a[1]+"Z",0,100,320,43,18,en2Z.val,"Adjust Z size")
402 ######################################################
403 CreaNew=Toggle(menu1a[8],98,10,295,129,18,CreaNew.val,"Create new objects or just modify selected?")
405 Cuantos=Number('',98,139,295,30,18,Cuantos.val,1,999,"Number of copies")
406 Button(menu1a[5],1,190,170,60,98,"Align") #Alinea
407 Button(menu1a[6],2,190,100,60,38,"Rotate") #Gira
408 Button(menu1a[9],3,190,30,29,38,"Scale +") #Escala+
409 Button(menu1a[10],7,220,30,30,38,"Scale *") #Escala*
410 Button(menu1a[2],6,147,320,45,38,"Fit active in one or two others using max limits (creates new object)") #Encaja
411 Button(menu1a[3],5,195,320,55,38,"Fit active in one or two others using min limits (creates new object)") #Abarca
413 def HaceArco(pts,ang1,angul,ctro,R):
416 alfa=(ang1+angul*c/(pts-1))*pi/180
441 def Exec_align(os,c,ali,eqi,sep):
446 m=o.data #Maya del objeto
449 for d in range(3): ctr[d]=Extremo(m.verts,o.matrix)[1][d]
450 elif(eqi[c]==3 or eqi[c]==6):
451 ctr=Extremo(m.verts,o.matrix)[0]
453 ctr=Extremo(m.verts,o.matrix)[2]
456 ctr=GloVrt(ctr,o.matrix)
458 if (eqi[c]>1): ademas=ctr[c]-o.loc[c]
459 if (flag): coor=coor-ademas
462 if(eqi[c]==6): ademas=Extremo(m.verts,o.matrix)[2][c]-o.loc[c]
463 coor=coor+sep[c]+ademas
466 if (evt==ESCKEY and not val):
470 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@22#
476 os=Blender.Object.GetSelected()
480 ##########MENU BUFFER
485 for c in range(3): BfL[c]=os[1].loc[c]-os[0].loc[c]
486 print "Copied to Loc buffer:",BfL
488 PupMenu('ERROR%t|Selecciona 2 objetos|Just select 2 objects!')
491 BfL=3*[sqrt((os[1].loc[0]-os[0].loc[0])**2+
492 (os[1].loc[1]-oa.loc[1])**2+
493 (os[1].loc[2]-oa.loc[2])**2)]
494 print "Copied to Loc buffer:",BfL
496 PupMenu('ERROR%t|Selecciona 2 objetos|Just select 2 objects!')
499 for c in range(3): BfR[c]=os[1].rot[c]-oa.rot[c]
500 print "Copied to Rot buffer:",BfR
502 PupMenu('ERROR%t|Selecciona 2 objetos|Just select 2 objects!')
503 if copi==4 and len(os):
505 for o in os: lista.append(o.loc)
507 print "Copied to Loc buffer:",BfL
509 for o in os: lista.append(o.rot)
511 for c in range(3): BfR[c]*=180/pi
512 print "Copied to Rot buffer:",BfR
514 for o in os: lista.append(o.size)
516 print "Copiado to Size buffer:",BfS
518 print"\n_Buffer contents_\n"
519 for c in range(3): print "Loc",coo[c]," :",BfL[c]
520 for c in range(3): print "Rot",coo[c]," :",BfR[c]
521 for c in range(3): print "Size",coo[c],":",BfS[c]
522 print "______________________"
526 X =[sepX.val,sepY.val,sepZ.val]
527 ali =[aliX.val,aliY.val,aliZ.val]
531 print"Copying to Loc buffer",coo[c],"value", BfL[c]
534 X =[incX.val,incY.val,incZ.val]
535 ali =[girX.val,girY.val,girZ.val]
539 print"Copying to Rot buffer",coo[c],"value", BfR[c]
542 X =[iScaX.val,iScaY.val,iScaZ.val]
543 ali =[scaX.val,scaY.val,scaZ.val]
547 print"Copying to Size buffer",coo[c],"value", BfS[c]
551 X =[sepX.val,sepY.val,sepZ.val]
552 ali =[aliX.val,aliY.val,aliZ.val]
556 print"Retrieving from buffer Loc",coo[c],"value", BfL[c]
557 sepX.val,sepY.val,sepZ.val=X
560 X =[incX.val,incY.val,incZ.val]
561 ali =[girX.val,girY.val,girZ.val]
565 print"Retrieving from buffer Rot",coo[c],"value", BfR[c]
566 incX.val,incY.val,incZ.val=X
569 X =[iScaX.val,iScaY.val,iScaZ.val]
570 ali =[scaX.val,scaY.val,scaZ.val]
574 print"Retrieving from buffer Size",coo[c],"value", BfS[c]
575 iScaX.val,iScaY.val,iScaZ.val=X
578 print"Retrieving <ApplyLocRotSize> matrix"
579 nLocX.val,nLocY.val,nLocZ.val=BfL
580 nRotX.val,nRotY.val,nRotZ.val=BfR
581 nSizX.val,nSizY.val,nSizZ.val=BfS
584 print"Retrieving float number to button"
585 x=[BfL[0],BfL[1],BfL[2],
586 sqrt(BfL[0]**2+BfL[1]**2+BfL[2]**2),
587 BfR[0],BfR[1],BfR[2],
588 BfS[0],BfS[1],BfS[2]]
589 numReal.val = x[menuPaste.val-1]
592 if moveke.val==1: # MOVER HACIA EL O.ACTIVO
593 oaV=Vector(list(oa.loc))
595 oV=Vector(list(o.loc))
596 v=oV-oaV #Calculo del vector final
601 elif movekomo.val==2:
603 elif movekomo.val==3:
607 if moveke.val==2: # MOVER AL AZAR
613 aliX.val * (2*n*random() - n),
614 aliY.val * (2*n*random() - n),
615 aliZ.val * (2*n*random() - n)])
617 if menuLRS.val==1: #Uso del vector final
618 oV=Vector(list(o.loc))
621 v=Vector(list(o.getEuler()))+v1
624 oV=Vector(list(o.size))
627 if evt==40: # PROYECTA EN PLANOS
631 if akeplano.val==1: #plano global
632 n[akeplanoXYZ.val-1]=1.
634 elif akeplano.val==2: n=oa.matrix[akeplanoXYZ.val-1] #plano local
638 if enkedir.val<4: d[enkedir.val-1]=1. #direccion global
639 elif enkedir.val==4: d=n #direc. ortog. al plano
641 n1 = Vector([-n[2],n[0],n[1]])
642 N1 = CrossVecs (n,n1)
643 N2 = CrossVecs (n,N1)
644 n.normalize(), N1.normalize(), N2.normalize()
645 #print"productos escalares (deben ser 0):",DotVecs(N1,n),DotVecs(N2,n),DotVecs(N2,N1)
648 [N1[0],N1[1],N1[2],0],
649 [N2[0],N2[1],N2[2],0],
650 [ n[0], n[1], n[2],0],
651 [ p[0], p[1], p[2],1])
655 dN=VecMultMat(d,NI.rotationPart())
657 PupMenu('Error%t|Operacion no permitida: la direccion esta en el plano%x1|Illegal operation: plane contains direction%x2')
659 print"Absolute direction:",d,"\nPlane normal:",n,"\nRelative direction:",dN
660 for o in filter(mallaScan,os[numObjs:]):
661 me=Blender.NMesh.GetRawFromObject(o.name)
664 v0=Vector([v[0],v[1],v[2]])
668 v[0] = v0[0] - v0[2]/dN[2] * dN[0]
669 v[1] = v0[1] - v0[2]/dN[2] * dN[1]
671 oo=Blender.Object.New('Mesh')
672 oo.setName(o.name+'Proy')
677 if(evt>9 and evt<17): # HACE ARCO INTERACTIV.
679 if(evt==11): angulo.val=ang2.val-ang1.val
680 if(evt==12 or evt==10): ang2.val=(ang1.val+angulo.val)
681 m=HaceArco(pts.val,ang1.val,angulo.val,ctro.val,radio.val)
684 if evt in [17,18]: # HACE ARCO CON 3 PTS.
688 if arcorden.val==1 or evt==18:
689 p1,p2,p3=m.verts[0],m.verts[1],m.verts[2]
690 elif arcorden.val==2:
691 p1,p2,p3=m.verts[1],m.verts[2],m.verts[0]
692 elif arcorden.val==3:
693 p1,p2,p3=m.verts[2],m.verts[0],m.verts[1]
699 print "Points:\n ",p1,p2,p3
704 M1=CrossVecs(p21,p31)
707 D2=DotVecs(p21,p1+p2)/2
708 D3=DotVecs(p31,p1+p3)/2
712 [p21[0],p21[1],p21[2]],
713 [p31[0],p31[1],p31[2]],
715 O=Sistema(SS,Vector([D,D2,D3]))
722 #Terna ortogonal: v2,vN,v3
723 R=sqrt(DotVecs(v2,v2))
724 RN=sqrt(DotVecs(vN,vN))
725 R3=sqrt(DotVecs(v3,v3))
727 if evt==18: angul=2*pi
728 else: angul=AngleBetweenVecs(v2,b3)
731 print "Radius :",R,"RN:",RN,"R3:",R3
733 M2=Matrix([v2[0]/R,v2[1]/R,v2[2]/R],[-v3[0]/R3,-v3[1]/R3,-v3[2]/R3],[vN[0]/RN,vN[1]/RN,vN[2]/RN])
735 arco=HaceArco(pts.val,0,angul,ctro.val,1)
736 oo=CreaObjDeMalla(arco,o,meTx.val+'.In')
738 EU=EU[0]*pi/180,EU[1]*pi/180,EU[2]*pi/180
739 oo.RotX,oo.RotY,oo.RotZ=EU[0],EU[1],EU[2]
745 arco=HaceArco(pts.val,0,angul,ctro.val,1)
746 oo=CreaObjDeMalla(arco,o,meTx.val+'.Ex')
747 oo.RotX,oo.RotY,oo.RotZ=EU[0],EU[1],EU[2]
751 if(evt==20): # SUBDIVIDE
752 for o in filter(mallaScan,os):
755 mm.name=m.name+'.Subdiv'
756 for v in m.verts: mm.verts.append(v)
759 for k1 in range(NV+1):
761 for k2 in range(NV-k1):
764 if (v1 in f.v) and (v2 in f.v): # SI...
765 dif=abs(f.v.index(v2)-f.v.index(v1))
766 if dif==1 or dif==len(f.v)-1: #...entonces f contiene la arista v1-v2
773 for c in range(3): v.co[c]=(v1.co[c]*(N-K-1)+v2.co[c]*(K+1))/N
777 mm.faces.append(cara)
778 break #para que no se repitan aristas comunes a varias caras
779 CreaObjDeMalla(mm,o,o.name+'.Subdiv')
781 if evt==30: # APLICA LOC.ROT.SIZE
782 for o in filter(mallaScan,os):
785 eu=Euler([nRotX.val,nRotY.val,nRotZ.val])
788 Mt=TranslationMatrix(Vector([nLocX.val,nLocY.val,nLocZ.val]))
791 o.setSize(nSizX.val,nSizY.val,nSizZ.val)
792 MI=o.getInverseMatrix()
796 w=list(VecMultMat(Vector([v[0],v[1],v[2],1]),P))
797 for c in range(3): v[c]=w[c]/o.size[c]
802 for oo in Blender.Object.Get():
803 if oo.data.name==maya.name and o!=oo:
806 oo.setSize(oo.SizeX*nSizX.val,oo.SizeY*nSizY.val,oo.SizeZ*nSizZ.val)
808 if((evt==5 or evt==6) and len(os)): # ENCAJA-ABARCA
809 enc=[encX.val,encY.val,encZ.val]
810 en2=[en2X.val,en2Y.val,en2Z.val]
811 me=GetRaw(oa.data.name)
814 w=GloVrt(v,oa.matrix)
820 n1=Extremo(os[1].data.verts,os[1].matrix)[0][c]
821 m1=Extremo(os[1].data.verts,os[1].matrix)[2][c]
823 n2=Extremo(os[2].data.verts,os[2].matrix)[0][c]
824 m2=Extremo(os[2].data.verts,os[2].matrix)[2][c]
825 n0=Extremo(meVs)[0] [c]
826 m0=Extremo(meVs)[2] [c]
829 if (len(os)==1): n1,m1=n0,m0
830 if (len(os)<3): n2,m2=n1,m1
833 n2,n1,m2,m1=n1,t,m1,s
834 print coo[c],n0,m0,n1,m1,n2,m2
838 if evt==5: pm2=(n2+m1)/2
842 if evt==5: factor=(n2-m1)/ancho
843 else: factor=(m2-n1)/ancho
844 v[c]=pm2+(v[c]-pm2)*factor
847 elif (evt==1 and len(os)):
848 ali=[aliX.val,aliY.val,aliZ.val]
849 eqi=[menueqiX.val,menueqiY.val,menueqiZ.val]
850 sep=[sepX.val,sepY.val,sepZ.val]
852 for o in filter(mallaScan,os):
854 for i in range(Cuantos.val):
855 newo=CreaObjDeMalla(o.getData(),o,o.name)
859 Exec_align(newos,c,ali,eqi,sep)
863 Exec_align(filter(mallaScan,os),c,ali,eqi,sep)
864 elif (evt==2 and len(os)):
865 gir=[girX.val,girY.val,girZ.val]
866 inc=[incX.val,incY.val,incZ.val]
868 for o in filter(mallaScan,os):
870 for i in range(Cuantos.val):
871 newo=CreaObjDeMalla(o.getData(),o,o.name)
878 valor=valor+inc[c]*pi/180
885 valor=valor+inc[c]*pi/180
887 elif evt in [3,7] and len(os):
888 sca=[scaX.val,scaY.val,scaZ.val]
889 inc=[iScaX.val,iScaY.val,iScaZ.val]
891 for o in filter(mallaScan,os):
893 for i in range(Cuantos.val):
894 newo=CreaObjDeMalla(o.getData(),o,o.name)
901 if evt==3: valor=valor+inc[c]
902 if evt==7: valor=valor*inc[c]
909 if evt==3: valor=valor+inc[c]
910 if evt==7: valor=valor*inc[c]
912 elif (evt==99): Exit()
915 #file=open(path+dirsep+'KUlang.txt','r')
916 #file=open(dirsep.join(path)+dirsep+'KUlang.txt','r')
918 file=open(join(path,'KUlang.txt'),'r')
919 fich=file.readlines()
920 print "\n\nKloputils",fich[0]
921 for i in range(len(fich)):
922 if fich[i]==Lang+'\012': break
923 print "Language:",fich[i]
924 menuExit=fich[i+1]#Sale prog.
925 menu0=fich[i+2]#Pral.
926 J=int(fich[i+3])#Alinea:botones
928 for j in range(J): menu1a.append(fich[i+j+4])
930 menu1b=fich[i+4]#Alinea:menu separa
931 menu2=str(fich[i+5])#Crea:menu
932 J=int(fich[i+6])#Crea:botones
934 for j in range(J): menu2a.append(fich[i+j+7])
936 menu3=fich[i+7]#Modif:menu
937 menu3a=fich[i+8]#Modif:"partes
938 menu3b=fich[i+9]#Modif:menu plano
939 menu3c=fich[i+10]#Modf:"Actua...
940 menu3d=fich[i+11]#Modif:menu dire
941 menu3e=fich[i+12]#Modf:"Captura
942 menu4=fich[i+13]#Buffer
943 menu5=fich[i+14]#ModifObjs
948 Register(draw,event,bevent)