less copy protection, more size visualization
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

65 lignes
1.9 KiB

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