Guest User

Untitled

a guest
Nov 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # coding=utf-8
  2. import os
  3.  
  4. def makeHBmaterials(divaFile,hbMatFileName='HoneybeeRadMaterials.mat'):
  5. """
  6. Take a DIVA material file and write a Honeybee-friendly material database. The written file needs to be placed
  7. inside the Ladybug root folder...Usually c:\ladybug.
  8. :param divaFile: File path for the diva material file.
  9. :param hbMatFileName: File path to which the Honeybee-friendly radiance materials should be written to.
  10. :return:
  11. """
  12. assert os.path.exists(divaFile),'The Diva materials file (%s) was not found.'%divaFile
  13.  
  14. hbStr = ""
  15. commentCount=0
  16. with open(divaFile) as divaData:
  17. for lines in divaData:
  18. lines=lines.strip()
  19. if lines:
  20. if lines.startswith("#"):
  21. commentCount+=1
  22. else:
  23. if commentCount>0:
  24. hbStr+='\n'
  25. commentCount=0
  26. hbStr+="%s\n"%lines
  27.  
  28. with open(hbMatFileName,'w') as writeMatData:
  29. writeMatData.write(hbStr)
  30.  
  31. if __name__ == "__main__":
  32. makeHBmaterials(r'C:\Users\ssubramaniam\Documents\My Received Files\HoneybeeRadMaterials.mat')
Add Comment
Please, Sign In to add comment