freecad_port
freecad.datamanager_wb.ports.freecad_port
¶
Ports and adapters for FreeCAD runtime access.
This module defines a small "port" interface that encapsulates the parts of the FreeCAD runtime needed by UI-facing orchestration code.
The goal is to keep FreeCAD-specific quirks (optional GUI module, duck-typed
objects, and defensive getattr usage) localized to a single adapter.
FreeCadContextAdapter(ctx)
dataclass
¶
Runtime adapter that implements :class:FreeCadPort using FreeCadContext.
ctx
instance-attribute
¶
add_selection(*, doc_name, obj_name)
¶
Add an object to GUI selection if the GUI is available.
Source code in freecad/datamanager_wb/ports/freecad_port.py
clear_selection()
¶
Clear GUI selection if the GUI is available.
Source code in freecad/datamanager_wb/ports/freecad_port.py
get_active_document()
¶
get_object(doc, name)
¶
Return an object by name from the given document, if possible.
Source code in freecad/datamanager_wb/ports/freecad_port.py
get_typed_object(doc, name, *, type_id)
¶
Return an object by name only if its TypeId matches.
Source code in freecad/datamanager_wb/ports/freecad_port.py
log(text)
¶
Write an informational message to the FreeCAD console/log.
Source code in freecad/datamanager_wb/ports/freecad_port.py
message(text)
¶
Write a normal message to the FreeCAD console/log.
Source code in freecad/datamanager_wb/ports/freecad_port.py
translate(context, text)
¶
Translate the given text for UI display.
Source code in freecad/datamanager_wb/ports/freecad_port.py
try_recompute_active_document()
¶
Attempt to recompute the active document, swallowing exceptions.
Source code in freecad/datamanager_wb/ports/freecad_port.py
try_update_gui()
¶
Attempt to update the GUI, swallowing exceptions.
Source code in freecad/datamanager_wb/ports/freecad_port.py
warn(text)
¶
Write a warning message to the FreeCAD console/log.
Source code in freecad/datamanager_wb/ports/freecad_port.py
FreeCadPort
¶
Port interface for the small slice of FreeCAD used by controllers.
add_selection(*, doc_name, obj_name)
¶
clear_selection()
¶
get_active_document()
¶
get_object(doc, name)
¶
get_typed_object(doc, name, *, type_id)
¶
log(text)
¶
message(text)
¶
translate(context, text)
¶
try_recompute_active_document()
¶
Attempt to recompute the active document.
This method must swallow all exceptions to keep the UI responsive.
try_update_gui()
¶
Attempt to update the FreeCAD GUI.
This method must swallow all exceptions to keep the UI responsive.
get_port(ctx=None)
¶
Return a :class:FreeCadPort backed by the given context.
When ctx is not provided, this function obtains the real FreeCAD runtime
context via :func:get_runtime_context.