less copy protection, more size visualization
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.4 KiB

  1. import bpy
  2. from mathutils import Vector, Euler
  3. from math import pi
  4. import json
  5. buildings = bpy.data.objects["map"].children
  6. c = bpy.data.objects["cam"]
  7. #s = bpy.data.objects["sun"]
  8. selected = bpy.context.selected_objects[0]
  9. data = {}
  10. data["name"] = selected.name
  11. data["place"] = ["Chicago"]
  12. data["views"] = {}
  13. for b in buildings:
  14. pick = b.name == data["name"]
  15. if not pick:
  16. b.hide_render = True
  17. else:
  18. b.hide_render = False
  19. b = selected
  20. for angles in [[0, 1, 2, "North"], [0.5, 1, 2, "Northwest"], [1, 1, 2, "West"], [0, 0, 1, "North (Top)"], [1, 0, 0, "West (Top)"]]:
  21. local_bbox_center = 0.125 * sum((Vector(box) for box in b.bound_box), Vector())
  22. global_bbox_center = b.matrix_world @ local_bbox_center
  23. c.location = global_bbox_center
  24. c.data.ortho_scale = max(b.dimensions) * 1.1
  25. c.rotation_euler = Euler([angles[1] * pi / 2, 0, angles[0] * pi / 2])
  26. rot = c.rotation_euler.to_matrix()
  27. rot.invert()
  28. c.location = c.location + Vector([0, 0, 10000]) @ rot
  29. data["views"][angles[3]] = b.dimensions[angles[2]]
  30. #s.rotation_euler = c.rotation_euler
  31. bpy.context.scene.render.filepath = f"C:/Users/hausss/Desktop/osm/{data['name']}-{angles[3]}.png"
  32. bpy.ops.render.render(write_still = True)
  33. with open(f"C:/Users/hausss/Desktop/osm/{data['name']}-data.json", "w") as file:
  34. json.dump(data, file)