Guest User

Untitled

a guest
Jan 10th, 2019
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. import bpy
  2.  
  3. card_x = 80
  4. card_y = 10
  5. card_z = 135
  6.  
  7. card_margin = 10
  8.  
  9. grid_x = 22
  10. grid_z = 5
  11.  
  12. backplate_x = (card_x + card_margin) * grid_x + card_margin
  13. backplate_y = 30
  14. backplate_z = (card_z + card_margin) * grid_z + card_margin
  15.  
  16. def draw_backplate():
  17.     bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0), radius=1)
  18.     bpy.ops.transform.resize(value=(backplate_x, backplate_y, backplate_z))
  19.     return bpy.context.scene.objects.active
  20.  
  21. def draw_cards():
  22.     bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0), radius=1)
  23.     bpy.ops.transform.resize(value=(card_x, card_y, card_z))
  24.     cards = bpy.context.scene.objects.active
  25.  
  26.     cards_x_modifier = cards.modifiers.new(name="CardsXArray", type="ARRAY")
  27.     cards_x_modifier.fit_type = "FIXED_COUNT"
  28.     cards_x_modifier.count = grid_x
  29.     cards_x_modifier.use_relative_offset = True
  30.     cards_x_modifier.relative_offset_displace = ((card_x + card_margin) / card_x, 0, 0)
  31.    
  32.     cards_z_modifier = cards.modifiers.new(name="CardsZArray", type="ARRAY")
  33.     cards_z_modifier.fit_type = "FIXED_COUNT"
  34.     cards_z_modifier.count = grid_z
  35.     cards_z_modifier.use_relative_offset = True
  36.     cards_z_modifier.relative_offset_displace = (0, 0, (card_z + card_margin) / card_z)
  37.    
  38.     return cards
  39.  
  40. def main():
  41.     draw_backplate()
  42.     draw_cards()
  43.    
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment