How to call a library correctly?

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

api doc ifcopenshell
https://ifcopenshell.github.io/docs/python/html/ifcopenshell-python/api-documentation.html

3 Likes