mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +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
|
import bonsai.tool as tool
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from bonsai.tool.brick import BrickStore
|
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]
|
IFC_CONNECTED_TYPE = Union[bpy.types.Material, bpy.types.Object]
|
||||||
@@ -105,8 +105,9 @@ class IfcStore:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_file():
|
def get_file():
|
||||||
if IfcStore.file is None:
|
if IfcStore.file is None:
|
||||||
IfcStore.path = bpy.context.scene.BIMProperties.ifc_file
|
IfcStore.path = cast(str, bpy.context.scene.BIMProperties.ifc_file)
|
||||||
if not os.path.isabs(IfcStore.path):
|
# 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))
|
IfcStore.path = os.path.abspath(os.path.join(bpy.path.abspath("//"), IfcStore.path))
|
||||||
if IfcStore.path:
|
if IfcStore.path:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class Ifc(bonsai.core.tool.Ifc):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_path(cls) -> str:
|
def get_path(cls) -> str:
|
||||||
|
"""Get absolute filepath to the IFC file, return empty string if file is not saved."""
|
||||||
return IfcStore.path
|
return IfcStore.path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user