{"id":9046,"library":"ifcopenshell","title":"IfcOpenShell","description":"IfcOpenShell is an open-source (LGPL) software library providing an API for working with the Industry Foundation Classes (IFC) data model, used in Building Information Modeling (BIM). The `ifcopenshell` Python library offers high-level bindings and utilities for reading, writing, and manipulating IFC files. It is currently at version 0.8.5 and receives updates aligning with the underlying C++ library, with an irregular release cadence.","status":"active","version":"0.8.5","language":"en","source_language":"en","source_url":"https://github.com/IfcOpenShell/IfcOpenShell","tags":["BIM","IFC","CAD","geometry","building-information-modeling"],"install":[{"cmd":"pip install ifcopenshell","lang":"bash","label":"For Python 3.10-3.14 (check official documentation for exact range)"}],"dependencies":[],"imports":[{"symbol":"ifcopenshell","correct":"import ifcopenshell"},{"note":"Importing 'open' directly can conflict with Python's built-in open() function.","wrong":"from ifcopenshell import open","symbol":"open","correct":"ifcopenshell.open(...)"},{"symbol":"template","correct":"ifcopenshell.template(...)"},{"note":"Replaced 'create_guid()' in v0.8 with 'guid.new()'.","wrong":"ifcopenshell.create_guid()","symbol":"guid.new","correct":"ifcopenshell.guid.new()"},{"note":"Used for configuring geometry processing parameters.","symbol":"geom.settings","correct":"settings = ifcopenshell.geom.settings()"}],"quickstart":{"code":"import ifcopenshell\nimport os\n\n# Create a new IFC4 file\nifc_file = ifcopenshell.template(schema=\"IFC4\")\n\n# Create a project entity\nproject_guid = ifcopenshell.guid.new()\nproject = ifc_file.create_entity(\"IfcProject\", project_guid)\nproject.Name = \"My First IfcOpenShell Project\"\n\n# Add the project to the file\nifc_file.add(project)\n\n# Define output path\noutput_path = \"my_first_project.ifc\"\n\n# Save the IFC file\nifc_file.write(output_path)\nprint(f\"Successfully created IFC file: {output_path}\")\n\n# Optional: Clean up the created file for repeated runs\nif os.path.exists(output_path):\n    os.remove(output_path)\n    print(f\"Cleaned up {output_path}\")","lang":"python","description":"This quickstart demonstrates how to create a new IFC file with a basic 'IfcProject' entity, save it to disk, and then clean up the generated file."},"warnings":[{"fix":"Review the official migration guide for v0.8. Specifically, `ifcopenshell.guid.new()` replaces `ifcopenshell.create_guid()`, and arguments for `ifcopenshell.geom.settings()` have changed.","message":"Major API changes occurred between v0.7 and v0.8, particularly in geometry processing and file creation. Code written for v0.7 will likely break in v0.8.","severity":"breaking","affected_versions":"0.8.x and later"},{"fix":"Always check the `requires_python` metadata on PyPI or the official documentation for the supported Python range. For v0.8.5, this is typically Python 3.10-3.14. If a wheel is unavailable, building from source is an option but significantly more complex.","message":"IfcOpenShell has strict Python version requirements and platform-specific binary wheels. Installation might fail if your Python version or operating system/architecture is not supported by a pre-built wheel.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `ifcopenshell.template(schema='IFC4')` for creating new IFC files. This provides better control over the IFC schema and initial setup.","message":"The `ifcopenshell.file.createIfcFile()` function is effectively superseded by `ifcopenshell.template()`, which offers a more robust and flexible way to create new IFC files.","severity":"deprecated","affected_versions":"0.8.x and later"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install ifcopenshell` in the correct virtual environment. Ensure your Python version is compatible with the latest IfcOpenShell release.","cause":"The ifcopenshell package was not installed or is not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'ifcopenshell'"},{"fix":"On Windows, install the latest Visual C++ Redistributables. Ensure your Python version matches a pre-built wheel available for your OS and architecture. Check `pip debug` output for more clues or consider using a different Python environment.","cause":"This usually indicates missing underlying C++ dependencies (e.g., Visual C++ Redistributables on Windows), or that a compatible binary wheel (`ifcopenshell-python`) could not be installed for your specific platform/Python version.","error":"ImportError: DLL load failed while importing _ifcopenshell: The specified module could not be found."},{"fix":"Replace `ifcopenshell.create_guid()` with `ifcopenshell.guid.new()` which generates a new GUID without arguments.","cause":"Attempting to use the deprecated `create_guid()` function with an argument, or using it at all in v0.8+ where it's been replaced.","error":"TypeError: guid.create_guid() takes 0 positional arguments but 1 was given"},{"fix":"If `by_id()` is used, it returns a single object. If `by_type()` might return one, convert to a list: `my_entities = list(ifc_file.by_type('IfcWall'))` or check `if isinstance(entity, list):` before iterating.","cause":"You are trying to iterate over a single IFC entity object, likely returned by `ifc_file.by_id()` or if a `by_type()` call only returned one result, without properly converting it to a list if iteration is intended.","error":"TypeError: argument of type 'IfcProduct' is not iterable"}]}