mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
BlenderBIM some data_dir / schema_dir workarounds (#1606)
* write process.log to a tempdir if data_dir is not writable * Don't include filename returned by data_dir and schema_dir chooser
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import bpy
|
||||
import time
|
||||
import json
|
||||
import tempfile
|
||||
import logging
|
||||
import webbrowser
|
||||
import ifcopenshell
|
||||
@@ -43,8 +44,11 @@ class ExportIFC(bpy.types.Operator):
|
||||
def _execute(self, context):
|
||||
start = time.time()
|
||||
logger = logging.getLogger("ExportIFC")
|
||||
path_log = os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log"),
|
||||
if not os.access(bpy.context.scene.BIMProperties.data_dir, os.W_OK):
|
||||
path_log = os.path.join(tempfile.mkdtemp(), "process.log")
|
||||
logging.basicConfig(
|
||||
filename=os.path.join(context.scene.BIMProperties.data_dir, "process.log"),
|
||||
filename=path_log,
|
||||
filemode="a",
|
||||
level=logging.DEBUG,
|
||||
)
|
||||
@@ -105,8 +109,11 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
||||
def execute(self, context):
|
||||
start = time.time()
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
path_log = os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log"),
|
||||
if not os.access(bpy.context.scene.BIMProperties.data_dir, os.W_OK):
|
||||
path_log = os.path.join(tempfile.mkdtemp(), "process.log")
|
||||
logging.basicConfig(
|
||||
filename=os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log"),
|
||||
filename=path_log,
|
||||
filemode="a",
|
||||
level=logging.DEBUG,
|
||||
)
|
||||
@@ -169,7 +176,7 @@ class SelectDataDir(bpy.types.Operator):
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BIMProperties.data_dir = self.filepath
|
||||
bpy.context.scene.BIMProperties.data_dir = os.path.dirname(self.filepath)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
@@ -184,7 +191,7 @@ class SelectSchemaDir(bpy.types.Operator):
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.BIMProperties.schema_dir = self.filepath
|
||||
bpy.context.scene.BIMProperties.schema_dir = os.path.dirname(self.filepath)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
||||
Reference in New Issue
Block a user