Skip to content

Linked file features#8242

Open
theoryshaw wants to merge 6 commits into
v0.8.0from
Linked_File_Features
Open

Linked file features#8242
theoryshaw wants to merge 6 commits into
v0.8.0from
Linked_File_Features

Conversation

@theoryshaw

@theoryshaw theoryshaw commented Jul 3, 2026

Copy link
Copy Markdown
Member

theoryshaw and others added 6 commits July 2, 2026 15:22
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>
@falken10vdl

Copy link
Copy Markdown
Contributor

@theoryshaw some comments form my side:

  • It looks that path handling is not fully consistent across the pr. Could absolute vs relative variants fail to match and end up creating duplicate linked document records?
  • Is IfcDocumentReference.Description intended to be the long-term storage for selector query metadata? This may mix implementation metadata with IFC document semantics and potentially conflict with user made descriptions.
  • Is md5(query)[:8] a sufficiently collision-resistant suffix for very long-lived IFC projects, or should a longer hash segment be allocated? Do not know how frequent is this in the industry...
  • Would it not be better to persist link transformations when locking (DisableEditingLink) rather than on depsgraph autosave events, since those callbacks can run very frequently even if they return quickly?

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants