Button that allows changing linked ifc project filepath

Example - https://files.catbox.moe/usc5cu.png
This commit is contained in:
Andrej730
2025-07-21 16:36:24 +05:00
parent adfe56c777
commit d66dd1be18
2 changed files with 13 additions and 3 deletions
@@ -615,6 +615,8 @@ class BIM_UL_links(UIList):
op.filepath = item.name
else:
row.prop(item, "name", text="")
op = row.operator("bim.select_uri_attribute", text="", icon="FILE_FOLDER")
op.attribute_data_path = tool.Blender.get_full_data_path(item, "name")
op = row.operator("bim.load_link", text="", icon="LINKED")
op.filepath = item.name
op = row.operator("bim.unlink_ifc", text="", icon="X")
+11 -3
View File
@@ -157,7 +157,7 @@ class SelectURIAttribute(bpy.types.Operator, ImportHelper):
bl_options = {"REGISTER", "UNDO"}
bl_description = "Select a local file"
attribute_data_path: bpy.props.StringProperty(name="Data Path") # pyright: ignore[reportRedeclaration]
"""Full data path to Attribute."""
"""Full data path to `Attribute`/string property."""
use_relative_path: bpy.props.BoolProperty( # pyright: ignore[reportRedeclaration]
name="Use Relative Path",
default=False,
@@ -168,8 +168,16 @@ class SelectURIAttribute(bpy.types.Operator, ImportHelper):
use_relative_path: bool
def execute(self, context):
attribute: Attribute = eval(self.attribute_data_path)
attribute.string_value = tool.Ifc.get_uri(self.filepath, use_relative_path=self.use_relative_path)
from bonsai.bim.prop import Attribute
filepath = tool.Ifc.get_uri(self.filepath, use_relative_path=self.use_relative_path)
attribute = eval(self.attribute_data_path)
if isinstance(attribute, Attribute):
attribute.string_value = filepath
else:
bpy_struct_path, _, attr_name = self.attribute_data_path.rpartition(".")
setattr(eval(bpy_struct_path), attr_name, filepath)
return {"FINISHED"}