Title: Circular import error in ifcopenshell.util.shape_builder prevents importing recipes that use ShapeBuilder (v0.8.4.post1) · Issue #7562 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: Circular import error in ifcopenshell.util.shape_builder prevents importing recipes that use ShapeBuilder (v0.8.4.post1) · Issue #7562 · IfcOpenShell/IfcOpenShell
X Title: Circular import error in ifcopenshell.util.shape_builder prevents importing recipes that use ShapeBuilder (v0.8.4.post1) · Issue #7562 · IfcOpenShell/IfcOpenShell
Description: Bug Description Description When attempting to import recipes that depend on ifcopenshell.util.shape_builder (such as OffsetObjectPlacements), a circular import error occurs. This prevents these recipes from being loaded or executed. Env...
Open Graph Description: Bug Description Description When attempting to import recipes that depend on ifcopenshell.util.shape_builder (such as OffsetObjectPlacements), a circular import error occurs. This prevents these re...
X Description: Bug Description Description When attempting to import recipes that depend on ifcopenshell.util.shape_builder (such as OffsetObjectPlacements), a circular import error occurs. This prevents these re...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/7562
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Circular import error in ifcopenshell.util.shape_builder prevents importing recipes that use ShapeBuilder (v0.8.4.post1)","articleBody":"### Bug Description\n\n## Description\n\nWhen attempting to import recipes that depend on `ifcopenshell.util.shape_builder` (such as `OffsetObjectPlacements`), a circular import error occurs. This prevents these recipes from being loaded or executed.\n\n## Environment\n\n- **ifcopenshell version**: 0.8.4.post1 (also affects 0.8.4)\n- **ifcpatch version**: 0.8.4\n- **Python version**: 3.11\n- **OS**: Linux (Docker container)\n\n## Minimal Reproduction\n\n```python\n# This fails with circular import error\nfrom ifcpatch.recipes.OffsetObjectPlacements import Patcher\n```\n\nOr when using ifcpatch:\n\n```python\nimport ifcopenshell\nimport ifcpatch\n\nifc_file = ifcopenshell.open(\"model.ifc\")\n\n# This fails when it tries to import the recipe\noutput = ifcpatch.execute({\n \"input\": \"model.ifc\",\n \"file\": ifc_file,\n \"recipe\": \"OffsetObjectPlacements\",\n \"arguments\": [\"0\", \"0\", \"1000\", \"true\", \"0\", \"0\", \"90\"]\n})\n```\n\n\n\n### Attachments\n\n_No response_\n\n### Debug and Error Output\n\n```true\n## Error Traceback\n\n\nTraceback (most recent call last):\n File \"\u003cstring>\", line 1, in \u003cmodule>\n File \"/usr/local/lib/python3.11/site-packages/ifcpatch/recipes/OffsetObjectPlacements.py\", line 24, in \u003cmodule>\n from ifcopenshell.util.shape_builder import ShapeBuilder\n File \"/usr/local/lib/python3.11/site-packages/ifcopenshell/util/shape_builder.py\", line 26, in \u003cmodule>\n import ifcopenshell.util.element\n File \"/usr/local/lib/python3.11/site-packages/ifcopenshell/util/element.py\", line 22, in \u003cmodule>\n import ifcopenshell.util.representation\n File \"/usr/local/lib/python3.11/site-packages/ifcopenshell/util/representation.py\", line 24, in \u003cmodule>\n import ifcopenshell.util.shape\n File \"/usr/local/lib/python3.11/site-packages/ifcopenshell/util/shape.py\", line 27, in \u003cmodule>\n from ifcopenshell.util.shape_builder import VectorType\nImportError: cannot import name 'VectorType' from partially initialized module 'ifcopenshell.util.shape_builder' (most likely due to a circular import) (/usr/local/lib/python3.11/site-packages/ifcopenshell/util/shape_builder.py)\n\n\n## Analysis\n\nThe circular import chain is:\n\n1. `shape_builder.py` imports `ifcopenshell.util.element`\n2. `element.py` imports `ifcopenshell.util.representation`\n3. `representation.py` imports `ifcopenshell.util.shape`\n4. `shape.py` imports `VectorType` from `ifcopenshell.util.shape_builder`\n5. But `shape_builder.py` hasn't finished initializing yet → **ImportError**\n\n## Affected Recipes\n\nAt minimum:\n- `OffsetObjectPlacements` (confirmed)\n- Potentially any other recipe that imports from `ifcopenshell.util.shape_builder`\n\n## Possible Solutions\n\n1. **Use `TYPE_CHECKING` for type hints**: Move the `VectorType` import in `shape.py` inside an `if TYPE_CHECKING:` block since it's only used for type annotations\n\n2. **Move type definitions**: Create a separate `types.py` module for shared type definitions like `VectorType`\n\n3. **Lazy imports**: Defer the import of `shape_builder` in `shape.py` until it's actually needed at runtime\n\n## Workaround\n\nAs a temporary workaround, you can pre-initialize `shape_builder` with a mock `VectorType` before importing the recipe:\n\n\nimport sys\nimport types\nfrom typing import Any\n\n# Create mock shape_builder with VectorType\nmock_shape_builder = types.ModuleType('ifcopenshell.util.shape_builder')\nmock_shape_builder.VectorType = Any\nsys.modules['ifcopenshell.util.shape_builder'] = mock_shape_builder\n\n# Import base modules (shape.py will use mock VectorType)\nimport ifcopenshell\nimport ifcopenshell.util.shape\n\n# Remove mock and import real module\ndel sys.modules['ifcopenshell.util.shape_builder']\nimport ifcopenshell.util.shape_builder\n\n# Now recipes work\nfrom ifcpatch.recipes.OffsetObjectPlacements import Patcher # Success!\n```","author":{"url":"https://github.com/jonatanjacobsson","@type":"Person","name":"jonatanjacobsson"},"datePublished":"2026-01-15T08:06:20Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/7562"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:463bc77e-6cda-64bf-2e9a-28461e33ca5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AAC8:212B26:7C9B38:ABDF6F:6B04AB05 |
| html-safe-nonce | 1cf76a35afae87be23f43d21cb8d78847aa6fd19955bfe1fa040260d346ae9f2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUM4OjIxMkIyNjo3QzlCMzg6QUJERjZGOjZCMDRBQjA1IiwidmlzaXRvcl9pZCI6IjQ0MzM1NzY4MDE2NTQzMTk4NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 528f9845540d0aba3df3d67bbb262a6222ff398cbe794bd11771b70e8bfd582d |
| hovercard-subject-tag | issue:3816442173 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/7562/issue_layout |
| twitter:image | https://opengraph.githubassets.com/02086ba55b5fea1af2bb8780167f3389731c867fea32a42d0f80767eda2d8244/IfcOpenShell/IfcOpenShell/issues/7562 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/02086ba55b5fea1af2bb8780167f3389731c867fea32a42d0f80767eda2d8244/IfcOpenShell/IfcOpenShell/issues/7562 |
| og:image:alt | Bug Description Description When attempting to import recipes that depend on ifcopenshell.util.shape_builder (such as OffsetObjectPlacements), a circular import error occurs. This prevents these re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonatanjacobsson |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1d110ea058a0915c1d8aa3fc2069fa15801e128f591e5762525abe77490ecb1 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ffa22a65e4c46d376940fe34b05e6a7e9c7fdb9b |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width