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.
 
 
 

62 lines
1.8 KiB

  1. import sys
  2. import re
  3. import json
  4. import glob
  5. # here's the import workflow:
  6. # 1. import buildings into blender
  7. # 2. use the blender-building.py script in blender while selecting a building to export images
  8. # 3. batch-trace and color the overlay images
  9. # 4. batch-trace the base images
  10. # 5. batch-expand all of the images
  11. # 6. use this script to combine the images and record the building data
  12. # 7. batch-crop the combined images
  13. # this script smashes two svgs together in a way that is,
  14. # to be frank, sacrilege
  15. def combine(base_path, highlight_path, output_path):
  16. base = open(base_path, "r", encoding="utf-8").read()
  17. highlight = open(highlight_path, "r", encoding="utf-8").read()
  18. base_data = re.search("<path.*?</svg>", base)[0][:-6]
  19. highlight_data = highlight.replace("</defs>", "</defs>" + base_data)
  20. with open(output_path, "w", encoding="utf-8") as f:
  21. f.write(highlight_data)
  22. if len(sys.argv) <= 1:
  23. print(f"Usage: {sys.argv[0]} [location name]")
  24. sys.exit(1)
  25. sides = [
  26. "North",
  27. "Northwest",
  28. "West",
  29. "North (Top)",
  30. "West (Top)"
  31. ]
  32. template = """ results.push(makeRealBuilding(
  33. "{0}",
  34. [
  35. {1}
  36. ]
  37. ))
  38. """
  39. side_strings = []
  40. for path in glob.glob("*.json"):
  41. with open(path, "r") as f:
  42. data = json.load(f)
  43. if data["place"] == [sys.argv[1]]:
  44. name = "./svgs/" + data["name"]
  45. for side in sides:
  46. base = name + "-" + side + "-base-01.svg"
  47. highlight = name + "-" + side + "-highlight-01.svg"
  48. result = name + "-" + side + ".svg"
  49. combine(base, highlight, result)
  50. side_strings.append(" [\"{0}\", {1}]".format(data["name"] + "-" + side, data["views"][side]))
  51. print(template.format(sys.argv[1] + " Buildings", ",\n".join(side_strings)))