Advertisement
SI50

corso Alek esercizio 7 lezione 8

May 17th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.89 KB | None | 0 0
  1. import bpy
  2. from math import pi
  3.  
  4. C=bpy.context
  5. D=bpy.data
  6. O=bpy.ops
  7.  
  8. for o in D.objects:
  9.     D.objects.remove(o)
  10. for m in D.meshes:
  11.     D.meshes.remove(m)
  12. for c in D.collections:
  13.     D.collections.remove(c)
  14.  
  15. class Tavolino:
  16.     def __init__(self,lar=2,lun=.8,spe=.05,alt=.7,dia=.05,gap=.05,loc=(0,0),rot=0,n_sedie=1):
  17.         rotrad=rot*2*pi/360
  18.         O.mesh.primitive_cube_add(size=2,location=(loc[0],loc[1],alt+spe/2),scale=(lar,lun,spe),rotation=(0,0,rotrad))
  19.         tavola=C.object
  20.         loc_x=lar/2-dia/2-gap
  21.         loc_y=lun/2-dia/2-gap
  22.         bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(loc_x,loc_y,-alt/2-spe/2))
  23.         gambo1=C.object
  24.         gambo1.parent=tavola
  25.         bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(loc_x,-loc_y,-alt/2-spe/2))
  26.         gambo2=C.object
  27.         gambo2.parent=tavola
  28.         bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(-loc_x,loc_y,-alt/2-spe/2))
  29.         gambo3=C.object
  30.         gambo3.parent=tavola
  31.         bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt,location=(-loc_x,-loc_y,-alt/2-spe/2))
  32.         gambo4=C.object
  33.         gambo4.parent=tavola
  34.        
  35.         def sedia(lun_s2,lun_s3):
  36.             O.mesh.primitive_cube_add(size=2,location=(lun_s2,0,-alt/2),scale=(lun/2,lun/2,spe))
  37.             seduta=C.object
  38.             seduta.parent=tavola
  39.             O.mesh.primitive_cube_add(size=2,location=(lun_s3,0,alt/4+spe),scale=(lun/2,lun/2,spe),rotation=(0,1.5707,0))
  40.             spalliera=C.object
  41.             spalliera.parent=seduta
  42.             loc_xs=lar/8-dia/2-gap*1.5
  43.             loc_ys=lun/3.5-dia/21-gap*1.5
  44.             bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt/2,location=(loc_xs,loc_ys,-alt/4-spe/2))
  45.             gambo1s=C.object
  46.             gambo1s.parent=seduta
  47.             bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt/2,location=(loc_xs,-loc_ys,-alt/4-spe/2))
  48.             gambo2s=C.object
  49.             gambo2s.parent=seduta
  50.             bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt/2,location=(-loc_xs,loc_ys,-alt/4-spe/2))
  51.             gambo3s=C.object
  52.             gambo3s.parent=seduta
  53.             bpy.ops.mesh.primitive_cylinder_add(vertices=64,radius=dia/2,depth=alt/2,location=(-loc_xs,-loc_ys,-alt/4-spe/2))
  54.             gambo4s=C.object
  55.             gambo4s.parent=seduta
  56.            
  57.            
  58.         if n_sedie == 1:
  59.             lun_s2 = lun+lun/2
  60.             lun_s3 = lun/4-spe/2            
  61.             sedia(lun_s2,lun_s3)
  62.         if n_sedie == 2:
  63.             lun_s2 = lun+lun/2
  64.             lun_s3 = lun/4-spe/2
  65.             sedia(lun_s2,lun_s3)
  66.             lun_s2 = -lun-lun/2
  67.             lun_s3 = -lun/4+spe/2
  68.             sedia(lun_s2,lun_s3)
  69.         if n_sedie == 0:
  70.             print("pizza")
  71.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement