mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Keep IfcStore.path as empty string if file is not saved
Previously it would get cwd value in that case as bpy.path.abspath("//") returns cwd if .blend is not saved.
This commit is contained in:
@@ -33,7 +33,7 @@ import bonsai.bim.handler
|
||||
import bonsai.tool as tool
|
||||
from pathlib import Path
|
||||
from bonsai.tool.brick import BrickStore
|
||||
from typing import Set, Union, Optional, TypedDict, Callable, NotRequired
|
||||
from typing import Set, Union, Optional, TypedDict, Callable, NotRequired, cast
|
||||
|
||||
|
||||
IFC_CONNECTED_TYPE = Union[bpy.types.Material, bpy.types.Object]
|
||||
@@ -105,8 +105,9 @@ class IfcStore:
|
||||
@staticmethod
|
||||
def get_file():
|
||||
if IfcStore.file is None:
|
||||
IfcStore.path = bpy.context.scene.BIMProperties.ifc_file
|
||||
if not os.path.isabs(IfcStore.path):
|
||||
IfcStore.path = cast(str, bpy.context.scene.BIMProperties.ifc_file)
|
||||
# Interpret relative paths as relative to .blend file.
|
||||
if IfcStore.path and not os.path.isabs(IfcStore.path):
|
||||
IfcStore.path = os.path.abspath(os.path.join(bpy.path.abspath("//"), IfcStore.path))
|
||||
if IfcStore.path:
|
||||
try:
|
||||
|
||||
@@ -58,6 +58,7 @@ class Ifc(bonsai.core.tool.Ifc):
|
||||
|
||||
@classmethod
|
||||
def get_path(cls) -> str:
|
||||
"""Get absolute filepath to the IFC file, return empty string if file is not saved."""
|
||||
return IfcStore.path
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user