mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #3046. Renaming drawings now updates all drawing references on sheets.
This commit is contained in:
@@ -871,6 +871,8 @@ class CreateDrawing(bpy.types.Operator):
|
||||
merged_polygons = merged_polygons.geoms
|
||||
elif type(merged_polygons) == shapely.Polygon:
|
||||
merged_polygons = [merged_polygons]
|
||||
else:
|
||||
merged_polygons = []
|
||||
|
||||
for polygon in merged_polygons:
|
||||
g = etree.Element("g")
|
||||
|
||||
@@ -308,9 +308,17 @@ def update_drawing_name(ifc, drawing_tool, drawing=None, name=None):
|
||||
new_location = drawing_tool.get_default_drawing_path(name)
|
||||
if old_location != new_location:
|
||||
ifc.run("document.edit_reference", reference=reference, attributes={"Location": new_location})
|
||||
old_location = ifc.resolve_uri(old_location)
|
||||
if drawing_tool.does_file_exist(old_location):
|
||||
drawing_tool.move_file(old_location, ifc.resolve_uri(new_location))
|
||||
resolved_old_location = ifc.resolve_uri(old_location)
|
||||
if drawing_tool.does_file_exist(resolved_old_location):
|
||||
drawing_tool.move_file(resolved_old_location, ifc.resolve_uri(new_location))
|
||||
|
||||
for reference in drawing_tool.get_references_with_location(old_location):
|
||||
ifc.run("document.edit_reference", reference=reference, attributes={"Location": new_location})
|
||||
sheet = drawing_tool.get_reference_document(reference)
|
||||
if not sheet:
|
||||
uri = ifc.resolve_uri(drawing_tool.get_document_uri(sheet, "LAYOUT"))
|
||||
if drawing_tool.does_file_exist(uri):
|
||||
drawing_tool.update_embedded_svg_location(uri, old_location, new_location)
|
||||
|
||||
|
||||
def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None):
|
||||
|
||||
@@ -1289,6 +1289,18 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
return document.DocumentReferences or []
|
||||
return document.HasDocumentReferences or []
|
||||
|
||||
@classmethod
|
||||
def get_references_with_location(cls, location):
|
||||
return [r for r in tool.Ifc.get().by_type("IfcDocumentReference") if r.Location == location]
|
||||
|
||||
@classmethod
|
||||
def update_embedded_svg_location(cls, uri, old_location, new_location):
|
||||
with open(uri, "r") as f:
|
||||
svg = f.read()
|
||||
svg = svg.replace(os.path.basename(old_location), os.path.basename(new_location))
|
||||
with open(uri, "w") as f:
|
||||
f.write(svg)
|
||||
|
||||
@classmethod
|
||||
def get_reference_description(cls, reference):
|
||||
return reference.Description
|
||||
@@ -1300,7 +1312,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
@classmethod
|
||||
def get_reference_element(cls, reference):
|
||||
if tool.Ifc.get_schema() == "IFC2X3":
|
||||
refs = [r for r in tool.Ifc.by_type("IfcRelAssociatesDocument") if r.RelatingDocument == reference]
|
||||
refs = [r for r in tool.Ifc.get().by_type("IfcRelAssociatesDocument") if r.RelatingDocument == reference]
|
||||
else:
|
||||
refs = reference.DocumentRefForObjects
|
||||
if refs:
|
||||
|
||||
Reference in New Issue
Block a user