ducpy.tessellate.shims ====================== .. py:module:: ducpy.tessellate.shims .. autoapi-nested-parse:: CAD and BIM tessellation and capture shims for ducpy. Matches the exact tessellation and geometry extraction logic used across Scopture and Ducflair runtimes (three-cad-viewer buffer JSON, ifcopenshell triangulation). Classes ------- .. autoapisummary:: ducpy.tessellate.shims.FontEnum Functions --------- .. autoapisummary:: ducpy.tessellate.shims.scopture_is_model_dependency_call ducpy.tessellate.shims.scopture_install_model_modules ducpy.tessellate.shims.scopture_install_fonts ducpy.tessellate.shims.scopture_flatten_candidates ducpy.tessellate.shims.scopture_install_animation ducpy.tessellate.shims.scopture_tessellate_to_buffer_json ducpy.tessellate.shims.scopture_install_ipython_stub ducpy.tessellate.shims.scopture_install_ifc_output_capture ducpy.tessellate.shims.scopture_install_dxf_output_capture ducpy.tessellate.shims.scopture_collect_model_file ducpy.tessellate.shims.scopture_collect_ifc_preview Module Contents --------------- .. py:function:: scopture_is_model_dependency_call() -> bool Return whether the current call stack is executing a duc_model module. .. py:function:: scopture_install_model_modules(model_modules: list[dict[str, Any]] | None, runtime_globals: dict[str, Any]) -> None Install one execution's model-element sources as a lazy Python package. .. py:class:: FontEnum(values: Any) Immutable font manifest with sequence, key, and attribute access. .. py:attribute:: _values .. py:attribute:: _by_name .. py:attribute:: _by_attribute :type: dict[str, str] .. py:method:: __iter__() .. py:method:: __len__() -> int .. py:method:: __getitem__(key: Any) -> Any .. py:method:: __getattr__(name: str) -> str .. py:method:: __repr__() -> str .. py:function:: scopture_install_fonts(mounted_external_files: dict[str, dict[str, str]]) -> None Register mounted TTF files with OCCT and expose name-based resolution. .. py:function:: scopture_flatten_candidates(*objs: Any) -> list[Any] Recursively flatten nested lists/tuples/sets of objects into a flat list. .. py:function:: scopture_install_animation(module, globals_dict) Collect ocp_vscode animation tracks for the most recently shown assembly. .. py:function:: scopture_tessellate_to_buffer_json(*objs: Any, **kwargs: Any) -> str Tessellate CAD objects and return a compact JSON payload using base64 buffers. Uses the instanced format {instances, shapes} with numpy_to_buffer_json encoding. The client-side three-cad-viewer renderer handles this format via decodeInstancedFormat(). .. py:function:: scopture_install_ipython_stub() -> None Install a stub for IPython.lib.pretty so build123d can import it. .. py:function:: scopture_install_ifc_output_capture(output_path: str, sandbox_path: Callable[[str | os.PathLike[str], str | pathlib.Path], pathlib.Path] | None = None) -> None Patch ifcopenshell.file.write to also write to output_path. .. py:function:: scopture_install_dxf_output_capture(output_path: str, sandbox_path: Callable[[str | os.PathLike[str], str | pathlib.Path], pathlib.Path] | None = None) -> None Patch ezdxf.document.Drawing.saveas to also write to output_path. .. py:function:: scopture_collect_model_file(globals_dict: dict[str, Any], fmt: str, output_path: str | pathlib.Path, max_model_file_bytes: int = 0, now_fn: Callable[[], int] | None = None) -> dict[str, Any] Find an ifcopenshell or ezdxf object in globals and write it to output_path. .. py:function:: scopture_collect_ifc_preview(globals_dict: dict[str, Any], output_path: str | pathlib.Path | None = None, max_preview_bytes: int = 0) -> str | None Tessellate an IFC model and return a compact JSON preview payload. Searches globals_dict for ifcopenshell.file objects, falls back to reading from output_path. Uses ifcopenshell.geom for triangulation.