Skip to content

compas_cadwork.utilities ¤

Classes¤

IFCExportSettings dataclass ¤

IFCExportSettings(grouping_type: ElementGroupingType = NONE, export_cover_geometry: bool = False, translate_local_frame: bool = False)

Represents settings for the ifc export.

Attributes:

  • grouping_type (:class:`ElementGroupingType`, optional) –

    Which element grouping type should be considered when exporting (e.g. group, subgroup)

  • export_cover_geometry ((bool, optional)) –

    True if cover geometry should be exported, False otherwise.

  • translate_local_frame ((bool, optional)) –

    If True, the local frame of the elements will be translated on export to the global frame set with utility_controller.set_global_origin.

IFCExporter ¤

IFCExporter(settings: IFCExportSettings | None = None)

Used to export elements to ifc files.

Sets the required global settings for the export and restores them after the export.

Methods:¤

cleanup ¤
cleanup()

Restores any global settings that were changed during the export.

export_elements_to_ifc ¤
export_elements_to_ifc(element_ids: list[int], filepath: str) -> None

Exports elements to ifc file.

Parameters:

  • element_ids (list(int)) –

    List of element ids to export.

  • filepath (str) –

    Path to the resulting ifc file.

  • settings (:class:`IFCExportSettings`) –

    Settings for the ifc export.

initialize ¤
initialize()

Sets any global settings that are required for the export.

Functions:¤

activate_elements ¤

activate_elements(elements: list[Element | int]) -> None

Activates the given elements in the cadwork viewport.

Parameters:

  • elements (list(:class:`compas_cadwork.datamodel.Element` or int)) –

    List of elements or element ids to activate.

disable_autorefresh ¤

disable_autorefresh() -> None

Disables the automatic refresh of the cadwork viewport.

enable_autorefresh ¤

enable_autorefresh() -> None

Enables the automatic refresh of the cadwork viewport.

force_refresh ¤

force_refresh() -> None

Forces a refresh of the cadwork viewport.

get_active_elements ¤

get_active_elements() -> list[Element]

Returns the currently selected elements in the cadwork viewport.

Returns:

  • list(:class:`compas_cadwork.datamodel.Element`)

    List of currently selected elements.

get_all_element_ids ¤

get_all_element_ids(include_instructions: bool = False) -> Generator[int, None, None]

Returns all element ids of the currently open cadwork document.

Parameters:

  • include_instructions (bool, default: False ) –

    If True, also include instruction elements in the result.

Returns:

  • generator(int)

    Generator of element ids.

get_all_elements ¤

get_all_elements(include_instructions: bool = False) -> Generator[Element, None, None]

Returns all element ids of the currently open cadwork document.

Parameters:

  • include_instructions (bool, default: False ) –

    If True, also include instruction elements in the result.

Returns:

  • generator(:class:`compas_cadwork.datamodel.Element`)

    Generator of elements.

get_all_elements_with_attrib ¤

get_all_elements_with_attrib(attrib_number, attrib_value=None)

Returns a generator containing all elements with the given user attribute set to the given value.

Parameters:

  • attrib_number (int) –

    The user attribute number to filter by.

  • attrib_value (str, default: None ) –

    The value the user attribute should have.

Returns:

  • generator(:class:`compas_cadwork.datamodel.Element`)

    Generator of elements

get_bounding_box_from_cadwork_object ¤

get_bounding_box_from_cadwork_object(element: int | Element) -> list[Point]

Returns the 8 vertices of an elements bounding box.

Parameters:

  • element (int or :class:`compas_cadwork.datamodel.Element`) –

    The element id or Element object.

Returns:

  • list(:class:`compas.geometry.Point`)

get_element_groups ¤

get_element_groups(is_wall_frame: bool = True) -> dict[str, ElementGroup]

Returns a dictionary mapping names of the available building subgroups to their elements.

Parameters:

  • is_wall_frame (bool, default: True ) –

    If True, only wall groups which contain a wall frame elements are returned, otherwise all groups are returned.

Returns:

  • dict(str, :class:`~compas_cadwork.datamodel.ElementGroup`)

    Dictionary of building group names mapped to an instance of ElementGroup.

get_element_groups_from_selection ¤

get_element_groups_from_selection(is_wall_frame: bool = True) -> dict[str, ElementGroup]

Return a dictionary of ElementGroups built from the currently selected elements.

get_filename ¤

get_filename() -> str

Returns the name of the currently open cadwork document.

get_plugin_home ¤

get_plugin_home() -> str

Returns the home root directory of the currently running plugin

get_user_point ¤

get_user_point()

Prompts the user to select a cadwork point in the viewport and returns the coordinates of the selected point.

Returns:

  • class:`~compas.geometry.Point`

hide_all_elements ¤

hide_all_elements() -> None

Hides all elements in the cadwork viewport.

hide_elements ¤

hide_elements(elements: list[Element | int]) -> None

Hides the given elements in the cadwork viewport.

Parameters:

  • elements (list(:class:`compas_cadwork.datamodel.Element` or int)) –

    List of elements or element ids to hide.

is_cadwork_window_in_dark_mode ¤

is_cadwork_window_in_dark_mode() -> bool

Returns true if cadwork is in dark_mode and false if not.

lock_elements ¤

lock_elements(elements: list[Element | int]) -> None

Locks the given elements in the cadwork viewport.

Parameters:

  • elements (list(:class:`compas_cadwork.datamodel.Element` or int)) –

    List of elements or element ids to lock.

remove_elements ¤

remove_elements(elements: list[Element | int]) -> None

Removes the given elements from the cadwork document.

Parameters:

  • elements (list(:class:`compas_cadwork.datamodel.Element` or int)) –

    List of elements or element ids to remove.

save_project_file ¤

save_project_file()

Saves the current cadwork project file.

show_all_elements ¤

show_all_elements() -> None

Shows all elements in the cadwork viewport.

unlock_elements ¤

unlock_elements(elements: list[Element | int]) -> None

Unlocks the given elements in the cadwork viewport.

Parameters:

  • elements (list(:class:`compas_cadwork.datamodel.Element` or int)) –

    List of elements or element ids to unlock.

zoom_active_elements ¤

zoom_active_elements()

zoom active elements

Parameters:

  • Returns

    None