Here is a new update of my [Revit] Change fittings reference level without moving it with :
- Updated to be used in pyRevit
- A new WPF GUI with a new option to select a level from your project list
- Better error handling which makes it easier to use
Find the short video tutorial here :
Full source code available here : https://github.com/CyrilWaechter/pyRevitMEP/tree/master/pyRevitMEP.tab/Tools.panel/ElementChangeLevel.pushbutton
Thanks a lot to :
- AngelSix for his great WPF tutorial
- Gui Talarico for his great «SelectFromList» example available in his RevitPythonWrapper
Unfortunately, python wrapper cannot be used in ironpython environment (or at least I didn’t success to do so). So I had to find another way to use it directly in Revit. I used shared library (.dll) which can be downloaded on sourceforge : http://sourceforge.net/projects/coolprop/files/CoolProp/5.1.1/shared_library/Windows/64bit/.
It was a little tricky for a non professional programmer like me to understand how to call this CoolProp.dll properly. ctypes tutorial describe how to do it with standard python library. CoolProp documentation says that CoolProp support stdcall and cdecl call which means that you are supposed to be able to use cdll and windll. I tried and failed with windll then I found a post on stackoverflow that describe the same process i used but with cdll. I still don’t understand why windll didn’t work but at least I can use CoolProp in an IronPython environment.
#Load CoolProp shared library
CP = ctypes.cdll.LoadLibrary("/PathTo/CoolProp.dll")
#making PropsSI function call shorter
PropsSI = CP.PropsSI
#Convert python data type entered in PropsSI function call to expected argtypes for PropsSI function in the .dll
PropsSI.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_double, ctypes.c_char_p, ctypes.c_double, ctypes.c_char_p)
#Convert returned value from .dll to desired data type which is a float in python
PropsSI.restype = ctypes.c_double
#You can then call PropsSI function as in previous article
For more info about data types check here
Next article will talk about how to add fluids in Revit using CoolProp power !