mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 13:36:25 +00:00
Button that allows changing linked ifc project filepath
Example - https://files.catbox.moe/usc5cu.png
This commit is contained in:
@@ -615,6 +615,8 @@ class BIM_UL_links(UIList):
|
|||||||
op.filepath = item.name
|
op.filepath = item.name
|
||||||
else:
|
else:
|
||||||
row.prop(item, "name", text="")
|
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 = row.operator("bim.load_link", text="", icon="LINKED")
|
||||||
op.filepath = item.name
|
op.filepath = item.name
|
||||||
op = row.operator("bim.unlink_ifc", text="", icon="X")
|
op = row.operator("bim.unlink_ifc", text="", icon="X")
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class SelectURIAttribute(bpy.types.Operator, ImportHelper):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Select a local file"
|
bl_description = "Select a local file"
|
||||||
attribute_data_path: bpy.props.StringProperty(name="Data Path") # pyright: ignore[reportRedeclaration]
|
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]
|
use_relative_path: bpy.props.BoolProperty( # pyright: ignore[reportRedeclaration]
|
||||||
name="Use Relative Path",
|
name="Use Relative Path",
|
||||||
default=False,
|
default=False,
|
||||||
@@ -168,8 +168,16 @@ class SelectURIAttribute(bpy.types.Operator, ImportHelper):
|
|||||||
use_relative_path: bool
|
use_relative_path: bool
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
attribute: Attribute = eval(self.attribute_data_path)
|
from bonsai.bim.prop import Attribute
|
||||||
attribute.string_value = tool.Ifc.get_uri(self.filepath, use_relative_path=self.use_relative_path)
|
|
||||||
|
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user