Linked file features#8242
Open
theoryshaw wants to merge 6 commits into
Open
Conversation
Linked models previously flattened every style to a flat diffuse-color material. Now, styles carrying an IfcExternallyDefinedSurfaceStyle that points to a .blend file get the referenced material appended into the link's .cache.blend, in both the chunked and instanced loading paths. Relative style locations resolve against the linked IFC, and appended materials are deduplicated and stripped of stale IFC ids. Multi-layer elements (IfcMaterialLayerSetUsage) are now routed through the instanced path and sliced with slice_layerset_mesh so each layer shows its material style, using the external material when available. slice_layerset_mesh gained a pluggable style-to-material resolver and no longer appends duplicate materials for layers sharing one style. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The reload_link dialog previously only exposed the query. It now also offers Use Relative Path (defaulting to the stored path form), Use Cache (default off, matching the old always-rebuild behavior), the False Origin Mode project settings, and an editable file path with a browse button. Since a file browser cannot open from inside a props dialog, the browse button runs a new bim.select_link_filepath operator that opens the browser preselected at the current file and reopens the reload dialog with the chosen path, carrying the in-progress dialog state through the round trip. Changing the path updates the link name/filepath and, when a host IFC exists, the IfcDocumentReference.Location and document name - so ReloadLink is now a tool.Ifc.Operator to keep those edits transactional. Script calls without arguments still preserve all stored link values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Link editing moves from the links header row into each list row as a lock/unlock toggle. Unlocking (bim.enable_editing_link) frees the handle for moving; any transform is persisted immediately by a depsgraph_update_post handler, so bim.edit_link and its explicit save step are removed. Locking (bim.disable_editing_link) saves the current location and locks the handle instead of restoring the old position - cancel/restore semantics no longer exist. The save math from EditLink now lives in tool.Project.save_link_transformation. Enable/disable operators accept a link_index (default -1 = active link), so several links can be edited at once and script calls stay backward compatible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…dels The queried-element highlight broke in two ways: layerset-sliced linked meshes contain ngons, so highlight triangles are now built from calc_loop_triangles instead of polygon vertices; and ID properties read back as IDPropertyArrays which GPUIndexBuf rejects, so selection geometry is converted to plain tuples. TRIS drawing is also gated on its own data instead of piggybacking on the edges check. Moved links now highlight at their displayed location: the ray-cast instance matrix is passed through to select_linked_element, and find_obj_root compares it against the empty and object matrices combined (instanced occurrence objects have non-identity local matrices), falling back to the collection's only instance when no matrix is available (e.g. select by GUID). bim.append_inspected_linked_element also places the appended element where the moved link is displayed, using the new tool.Project.calculate_link_delta_matrix helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Linking the same file twice with different queries previously collided on the single shared .ifc.cache.blend: Blender reuses the loaded library per path, so both links displayed whichever query was cached first (and the other after reopening). Cache blend/json filenames now include a hash of the query (tool.Project.get_link_cache_paths), so each query gets its own library. The empty query keeps the legacy names, and the property sqlite stays shared since it always contains the whole file. All cache-path consumers were updated, including the per-link selectability/visibility toggles which would otherwise affect every link of the file at once. Query persistence moves from the shared sidecar JSON to the per-link IfcDocumentReference.Description (IFC4+, written by link_ifc and reload_link), restored on project load with a legacy JSON fallback that only applies when a file has a single link. The appended-element placement now matches links by the queried instance root empty since filepath alone is ambiguous with several links per file. LoadLink and ReloadLink volatile properties are marked SKIP_SAVE: Blender reuses last-used operator properties on the next interactive invocation, which leaked one link's query into another's load (and would corrupt ReloadLink's is_property_set logic the same way). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Living design note per the docs/dev-notes convention: problem, key facts (library-per-path reuse, SKIP_SAVE last-used-property retention, IfcDocumentReference conventions, link matrix math), per-feature design decisions, commit map, and open test items. Generated with the assistance of an AI coding tool. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
@theoryshaw some comments form my side:
Cheers! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dev notes: https://github.com/IfcOpenShell/IfcOpenShell/blob/f6cec0c9a5fb59453bf7cd6b44a2323fdaf81a8a/docs/dev-notes/linked-file-features.md