mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:43:46 +00:00
Fix issues printing drawing with projects linked by relative path
The fix in f9bf889 wasn't related to this problem and was targetting another bug.
This commit is contained in:
@@ -46,7 +46,7 @@ import bonsai.bim.export_ifc
|
|||||||
from bpy_extras.io_utils import ImportHelper
|
from bpy_extras.io_utils import ImportHelper
|
||||||
from bonsai.bim.module.drawing.decoration import CutDecorator
|
from bonsai.bim.module.drawing.decoration import CutDecorator
|
||||||
from bonsai.bim.module.drawing.data import DecoratorData, DrawingsData
|
from bonsai.bim.module.drawing.data import DecoratorData, DrawingsData
|
||||||
from typing import NamedTuple, List, Union, Optional, Literal
|
from typing import NamedTuple, List, Union, Optional, Literal, TYPE_CHECKING, Any
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from math import radians
|
from math import radians
|
||||||
from mathutils import Vector, Color, Matrix
|
from mathutils import Vector, Color, Matrix
|
||||||
@@ -56,6 +56,9 @@ from bonsai.bim.ifc import IfcStore
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from bpy_extras.image_utils import load_image
|
from bpy_extras.image_utils import load_image
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from bonsai.bim.module.project.prop import Link
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
|
||||||
@@ -833,9 +836,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
for link in props.links:
|
for link in props.links:
|
||||||
if not link.is_loaded:
|
if not link.is_loaded:
|
||||||
continue
|
continue
|
||||||
if link.name not in IfcStore.session_files:
|
files[link.name] = self.get_linked_file(link)
|
||||||
IfcStore.session_files[link.name] = ifcopenshell.open(link.name)
|
|
||||||
files[link.name] = IfcStore.session_files[link.name]
|
|
||||||
|
|
||||||
target_view = ifcopenshell.util.element.get_psets(self.camera_element)["EPset_Drawing"]["TargetView"]
|
target_view = ifcopenshell.util.element.get_psets(self.camera_element)["EPset_Drawing"]["TargetView"]
|
||||||
self.setup_serialiser(target_view)
|
self.setup_serialiser(target_view)
|
||||||
@@ -1242,34 +1243,41 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
self.is_manifold_cache[obj.data.name] = True
|
self.is_manifold_cache[obj.data.name] = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_element_by_guid(self, guid):
|
def get_linked_file(self, link: "Link") -> ifcopenshell.file:
|
||||||
|
link_path = link.name
|
||||||
|
ifc_file = IfcStore.session_files.get(link_path, None)
|
||||||
|
if ifc_file is not None:
|
||||||
|
return ifc_file
|
||||||
|
resolved_path = tool.Ifc.resolve_uri(link_path)
|
||||||
|
ifc_file = IfcStore.session_files[link_path] = ifcopenshell.open(resolved_path)
|
||||||
|
return ifc_file
|
||||||
|
|
||||||
|
def get_element_by_guid(self, guid: str) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
try:
|
try:
|
||||||
return tool.Ifc.get().by_guid(guid)
|
return tool.Ifc.get().by_guid(guid)
|
||||||
except:
|
except RuntimeError:
|
||||||
props = tool.Project.get_project_props()
|
props = tool.Project.get_project_props()
|
||||||
for link in props.links:
|
for link in props.links:
|
||||||
if link.name not in IfcStore.session_files:
|
ifc_file = self.get_linked_file(link)
|
||||||
IfcStore.session_files[link.name] = ifcopenshell.open(link.name)
|
|
||||||
try:
|
try:
|
||||||
return IfcStore.session_files[link.name].by_guid(guid)
|
return ifc_file.by_guid(guid)
|
||||||
except:
|
except RuntimeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def get_element_by_id(self, step_id):
|
def get_element_by_id(self, step_id: Any) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
try:
|
try:
|
||||||
step_id = int(step_id)
|
step_id = int(step_id)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
return tool.Ifc.get().by_id(step_id)
|
return tool.Ifc.get().by_id(step_id)
|
||||||
except:
|
except RuntimeError:
|
||||||
props = tool.Project.get_project_props()
|
props = tool.Project.get_project_props()
|
||||||
for link in props.links:
|
for link in props.links:
|
||||||
if link.name not in IfcStore.session_files:
|
ifc_file = self.get_linked_file(link)
|
||||||
IfcStore.session_files[link.name] = ifcopenshell.open(link.name)
|
|
||||||
try:
|
try:
|
||||||
return IfcStore.session_files[link.name].by_id(step_id)
|
return ifc_file.by_id(step_id)
|
||||||
except:
|
except RuntimeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def remove_cut_linework(self, root):
|
def remove_cut_linework(self, root):
|
||||||
|
|||||||
Reference in New Issue
Block a user