Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- card_x = 80
- card_y = 10
- card_z = 135
- card_margin_x = 20
- card_margin_z = 20
- grid_x = 8 #22
- grid_z = 2 #5
- backplate_x = (card_x + card_margin_x) * grid_x + card_margin_x
- backplate_y = 30
- backplate_z = (card_z + card_margin_z) * grid_z + card_margin_z
- backplate_glass_x = backplate_x
- backplate_glass_y = 1
- backplate_glass_z = backplate_z
- def draw_backplate():
- bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0), radius=1)
- bpy.ops.transform.resize(value=(backplate_x, backplate_y, backplate_z))
- backplate = bpy.context.scene.objects.active
- backplate.name = "Backplate"
- return backplate
- def carve_cards(backplate):
- loc_x = -backplate_x + card_x + 2 * card_margin_x
- loc_y = backplate_y
- loc_z = -backplate_z + card_z + 2 * card_margin_z
- bpy.ops.mesh.primitive_cube_add(location=(loc_x, loc_y, loc_z), radius=1)
- bpy.ops.transform.resize(value=(card_x, 2 * card_y, card_z))
- carve_cards = bpy.context.scene.objects.active
- cards_x_modifier = carve_cards.modifiers.new(name="CardsXArray", type="ARRAY")
- cards_x_modifier.fit_type = "FIXED_COUNT"
- cards_x_modifier.count = grid_x
- cards_x_modifier.use_relative_offset = True
- cards_x_modifier.relative_offset_displace = ((card_x + card_margin_x) / card_x, 0, 0)
- cards_z_modifier = carve_cards.modifiers.new(name="CardsZArray", type="ARRAY")
- cards_z_modifier.fit_type = "FIXED_COUNT"
- cards_z_modifier.count = grid_z
- cards_z_modifier.use_relative_offset = True
- cards_z_modifier.relative_offset_displace = (0, 0, (card_z + card_margin_z) / card_z)
- backplate_modifier = backplate.modifiers.new(name="BackplateBoolean", type="BOOLEAN")
- backplate_modifier.operation = "DIFFERENCE"
- backplate_modifier.object = carve_cards
- bpy.context.scene.objects.active = backplate
- bpy.ops.object.modifier_apply(modifier=backplate_modifier.name)
- bpy.data.objects.remove(carve_cards, True)
- def draw_cards():
- loc_x = -backplate_x + card_x + 2 * card_margin_x
- loc_y = backplate_y - card_y
- loc_z = -backplate_z + card_z + 2 * card_margin_z
- bpy.ops.mesh.primitive_cube_add(location=(loc_x, loc_y, loc_z), radius=1)
- bpy.ops.transform.resize(value=(card_x, card_y, card_z))
- cards = bpy.context.scene.objects.active
- cards.name = "Cards"
- cards_x_modifier = cards.modifiers.new(name="CardsXArray", type="ARRAY")
- cards_x_modifier.fit_type = "FIXED_COUNT"
- cards_x_modifier.count = grid_x
- cards_x_modifier.use_relative_offset = True
- cards_x_modifier.relative_offset_displace = ((card_x + card_margin_x) / card_x, 0, 0)
- cards_z_modifier = cards.modifiers.new(name="CardsZArray", type="ARRAY")
- cards_z_modifier.fit_type = "FIXED_COUNT"
- cards_z_modifier.count = grid_z
- cards_z_modifier.use_relative_offset = True
- cards_z_modifier.relative_offset_displace = (0, 0, (card_z + card_margin_z) / card_z)
- return cards
- def draw_backplate_glass():
- bpy.ops.mesh.primitive_cube_add(location=(0, backplate_y + backplate_glass_y, 0), radius=1)
- bpy.ops.transform.resize(value=(backplate_glass_x, backplate_glass_y, backplate_glass_z))
- backplate_glass = bpy.context.scene.objects.active
- backplate_glass.name = "Backplate Glass"
- return backplate_glass
- def main():
- backplate = draw_backplate()
- carve_cards(backplate)
- #draw_cards()
- draw_backplate_glass()
- main()
Advertisement
Add Comment
Please, Sign In to add comment