python-materialsdb inside Revit

You might be aware that you can use CPython script inside pyRevit using #! python3 at the beginning of your script file. The library which allow this is pythonnet. I encountered some issues:

  • pathlib module was not working because it was using ironpython version from pyrevitlib. Why ? python path. CPython site-packages path came after ironpython sites-packages path. Workaround: put pathlib.pyc in your <extension_path>\lib folder but it might be an issue if another script uses ironpython version. See issue #1287.
  • I have not found yet how to make a GUI inside Revit inside a CPython script. tkinter is not packaged with embedded python interpreter. wpf does not work the same way with pythonnet. Windows Forms might work.

What the script does at the moment is creating a .rvt file for each producer. It creates materials including main thermal properties. It also create hatches and apply colors based on a .json template produced with ExportMaterialsGraphics script which serialize all this parameters. Doing so I discovered how complex hatch are stored with in a list of FillGrid. Whatever the shape of your hatch, it is stored as a list of segments.

Source code is available here. I made a short video (in French) to explain how to use it currently.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.