Hello,
I try to call a library - ifcopenshell
so the idea is to get the ifcClasses which are adressed to the elements
# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib\ifcopenshell')
from ifcopenshell import *
elem = UnwrapElement(IN[0])
ifcelem = []
for i in elem:
ifcelem.append(i.ifc.by_type)
OUT = ifcelem
I want to get from my “Airelements” the IfcClass.
How is the process of “installing” a library? at moment i did just drag/drop/unzip…
Thats my library i work with ironpython 2.7.
is my path correct? or my syntex ? how can i deal with it. I check in Revit an IFC file
KR
Andreas
Hello
I’m not sure that I understand the end goal but as you have already imported the ifc in Revit why not use the parameter “IfcExportAs”
… but got the Parameter filled automaticly during the first ifc export?
IfcExportAs have i to fill it manually? where can i get my “Ifc”-Categories? is it just the mappingtable under options? it should be stored in the element? or Can I create it the first time when i export?
in that model that i got it is not activ this parameter! it is just expost to any coordinationsoftware… so Revit is unable to extract this information? f.e. i could also get modell from Microstation, so how can i get the IfcClasses
Draxl_Andreas:
but got the Parameter filled automaticly during the first ifc export?
IfcExportAs have i to fill it manually? where can i get my “Ifc”-Categories? is it just the mappingtable under options? it should be stored in the element? or Can I create it the first time when i export?
this Autodesk’s guide can be help you
here a simple example, if your goal is to control the Ifc Classes of a Revit export
import clr
import sys
import re
import System
reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import ifcopenshell
ifc_file = ifcopenshell.open(IN[0])
products = ifc_file.by_type('IfcProduct')
out = {}
for product in products:
rvtid = product.Name.split(':')[-1]
if rvtid.isdigit() :
out[product.GlobalId] = {"GuidIfc" : product.GlobalId,
"Name" : product.Name,
"rvt_Id" : rvtid,
"class": product.is_a()}
OUT = out
extract the zip package here
Note;
as I already told you, ifcopenshell package is not compatible with IronPython2
Hello @Draxl_Andreas
ifcopenshell is not a pure python library, it contains Windows dll file (pyd files)
Ironpython engine currently does not support using PYDs built for CPython since they leverage implementation details of CPython.
Try with CPython engine (Revit 2022+)
api doc ifcopenshell
https://ifcopenshell.github.io/docs/python/html/ifcopenshell-python/api-documentation.html
3 Likes
Thank you very much!
I have still problems calling the path… my path is currently this way:
C:\Users\DraxlA.WERKSTATT\AppData\Local\python-3.8.3-embed-amd64\Lib\site-packages
I created Lib and site-packages and put ifcopenshell there …hmm
can i write the full path ( “C:\Users\DraxlA.WERKSTATT\AppData\Local\python-3.8.3-embed-amd64\Lib\site-packages\ifcopenshell”)
Hi @Draxl_Andreas
for Dynamo 2.13 need to paste the package in 3.8.10 directory
C:\Users\USERNAME\AppData\Local\python-3.8.10-embed-amd64\Lib\site-packages
you need this version (64bits)
1 Like
Thank you, i had to open close Revit. It works!
1 Like