|
|
|
@ -17,6 +17,7 @@ except ImportError:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STATE_WRITEBACK_OBSERVER = "_qet_exchange_writeback_observer"
|
|
|
|
STATE_WRITEBACK_OBSERVER = "_qet_exchange_writeback_observer"
|
|
|
|
|
|
|
|
ENV_JSON_PATH = "QET_2D_TO_3D_JSON"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExchangeWriteBackError(RuntimeError):
|
|
|
|
class ExchangeWriteBackError(RuntimeError):
|
|
|
|
@ -110,6 +111,13 @@ def _output_path_for_scene(scene_path):
|
|
|
|
return str(path.parent / "3d_to_2d.json")
|
|
|
|
return str(path.parent / "3d_to_2d.json")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _output_path_for_exchange_json():
|
|
|
|
|
|
|
|
json_path = os.environ.get(ENV_JSON_PATH, "").strip()
|
|
|
|
|
|
|
|
if not json_path:
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return str(Path(json_path).with_name("3d_to_2d.json"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _format_timestamp():
|
|
|
|
def _format_timestamp():
|
|
|
|
return datetime.now().astimezone().isoformat(timespec="seconds")
|
|
|
|
return datetime.now().astimezone().isoformat(timespec="seconds")
|
|
|
|
|
|
|
|
|
|
|
|
@ -174,7 +182,7 @@ def write_back_document(doc=None, scene_path="", payload=None):
|
|
|
|
raise ExchangeWriteBackError("No active FreeCAD document is available.")
|
|
|
|
raise ExchangeWriteBackError("No active FreeCAD document is available.")
|
|
|
|
|
|
|
|
|
|
|
|
scene_path = _scene_path_from_doc(doc, scene_path)
|
|
|
|
scene_path = _scene_path_from_doc(doc, scene_path)
|
|
|
|
output_path = _output_path_for_scene(scene_path)
|
|
|
|
output_path = _output_path_for_exchange_json() or _output_path_for_scene(scene_path)
|
|
|
|
if not output_path:
|
|
|
|
if not output_path:
|
|
|
|
raise ExchangeWriteBackError(
|
|
|
|
raise ExchangeWriteBackError(
|
|
|
|
"Cannot determine the 3d_to_2d.json output path."
|
|
|
|
"Cannot determine the 3d_to_2d.json output path."
|
|
|
|
|