Favorites¶
Read, create and organize Favorites, apply their settings, and import or export Favorite files.
Access this group through api.tapir.favorites.
Commands¶
No commands match. Try another name or clear the filter.
For exceptions shared by Unified API commands, see error handling.
apply_favorite_to_tool_default ¶
apply_favorite_to_tool_default(
favorite_name: str,
) -> ElementType
Makes the settings of the given Favorite the settings of its tool, and returns the element type of that tool. Available from Archicad 29.
Parameters:
-
favorite_name(str) –The name of the Favorite whose settings become the settings of its tool.
Returns:
-
ElementType–The element type of the tool whose settings changed.
apply_favorites_to_element_defaults ¶
apply_favorites_to_element_defaults(
favorites: list[str],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Apply the given favorites to element defaults.
Parameters:
-
favorites(list[str]) –A list of favorite names
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
apply_favorites_to_elements ¶
apply_favorites_to_elements(
favorites_to_apply: None | list[FavoriteToApply] = None,
apply_settings: None | bool = None,
apply_classifications: None | bool = None,
apply_categories: None | bool = None,
apply_properties: None | bool = None,
keep_fields: None | list[FavoriteKeepField] = None,
*,
favorite: None | str = None,
elements: None | list[ElementIdArrayItem] = None,
filter: ElementTypeFloorLayerFilter | None = None,
setting_groups: None
| list[FavoriteSettingGroup] = None,
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Apply the given favorites to existing elements. Only settings-type parameters are changed - geometry (position, floor, and dimensions such as a Wall's height) is left untouched, so applying a Favorite never moves the target element. A Window or Door keeps its wall, marker and placement, and takes the Favorite's library part and parameters, size included. For the hierarchical types (Stair, Railing, Curtain Wall) the settings of the sub-elements are not applied, because they are inseparable from the Favorite's own geometry. The cross section of a Column or Beam is a Favorite setting and is applied too. By default settings, classifications, categories and properties are all applied; each can be opted out of individually. keepFields lists fields of the target (its ID, layer, an opening's width, height and sill height, a Wall's reference line location, height and top link, a Column's height, top link and cross section width and depth, a Beam's cross section width and height) that are copied back after the Favorite has been applied, so that e.g. only the library part or the wall type changes. settingGroups is the positive list instead: e.g. only FloorPlanAndSection applies just the pens, line types, story visibility and cut and cover fills of a Column or Beam, and nothing else of the Favorite. With favorite instead of favoritesToApply, one Favorite is read once and applied to the given elements, or to every element of its type that matches the filter.
Parameters:
-
favorites_to_apply(None | list[FavoriteToApply], default:None) –The elements and the Favorite to apply to each. Give this or favorite.
-
apply_settings(None | bool, default:None) –Whether to apply the Favorite's settings-type parameters (structure, materials, pens, etc.). Geometry (position, floor, and dimensions such as a Wall's height) is never applied - the element stays on its own home story - except that a Window or Door takes the Favorite's library part and parameters, size included, while keeping its wall, marker and placement. A Stair keeps its own baseline and flight width. For the hierarchical types (Stair, Railing, Curtain Wall) the settings of the sub-elements are not applied, because they are inseparable from the Favorite's own geometry. A Dimension's text size, text pen and text frame are not changed (tested in Archicad 28): the dimension creation commands take textHeight, textPen and textFrame for them. Default is true.
-
apply_classifications(None | bool, default:None) –Whether to apply the Favorite's classifications. Default is true.
-
apply_categories(None | bool, default:None) –Whether to apply the Favorite's element categories (e.g. IFC categories). Default is true.
-
apply_properties(None | bool, default:None) –Whether to apply the Favorite's property values. Default is true.
-
keep_fields(None | list[FavoriteKeepField], default:None) –Fields of the target element to keep: after the Favorite has been applied, they are copied back from the target as it was before, so only the Favorite's other settings (e.g. its library part or wall type) take effect. 'id' and 'layerIndex' apply to every element type; 'width', 'height' and 'sillHeight' to a Window or Door ('width' and 'height' also to a Skylight); 'height', 'topOffset' and 'relativeTopStory' to a Wall or Column; 'referenceLineLocation' to a Wall; 'width' and 'depth' (the cross section) to a Column, and 'width' and 'height' (the cross section) to a Beam. The cross section of a Column or Beam is a Favorite setting and is applied unless it is kept. A field the target's type does not have is ignored. To keep a Wall's or Column's top exactly as it was, keep 'height', 'relativeTopStory' and 'topOffset' together - a kept 'height' alone is recomputed by Archicad while the Favorite's relativeTopStory links the top to a story. Default: nothing is kept.
-
favorite(None | str, default:None) –The name of one Favorite to apply to many elements, instead of favoritesToApply: to the given elements, or without elements to every element of the Favorite's type that matches the filter. The Favorite is read only once. Needs elements or filter.
-
elements(None | list[ElementIdArrayItem], default:None) –The elements to apply the single favorite to, one execution result each, in the same order. Only with favorite.
-
filter(ElementTypeFloorLayerFilter | None, default:None) –Server-side element filter for the single favorite. Without elements the favorite is applied to every element of its type that matches it; an element of elements that does not match it gets a failed execution result. Only with favorite.
-
setting_groups(None | list[FavoriteSettingGroup], default:None) –Apply only these panels of the Favorite's settings dialog, and nothing else of it - a positive list instead of keepFields. 'FloorPlanAndSection' applies the Floor Plan and Section settings: story visibility (Show on Stories), floor plan display and projection, the pens and line types of the cut, uncut, overhead and hidden lines (a Beam's reference axis too), the cut fill pens and the cover fill; geometry, size, cross section, building material, profile, layer and the other panels stay the target's. It is supported for Column and Beam elements; another element type gets a failed execution result and is left unchanged. 'ClassificationAndProperties' applies the Favorite's classifications, element categories (e.g. structural function) and property values, each still only when its own apply flag is not false; without it in the list none of them is applied. applySettings false turns 'FloorPlanAndSection' off. keepFields still applies. Default: the whole Favorite is applied as described for applySettings.
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
change_favorite ¶
change_favorite(
favorite_name: str, source: FavoriteSettingsSource
) -> SuccessfulExecutionResult
Gives an existing Favorite the settings of another Favorite or of the current Opening tool default. Available from Archicad 29.
Parameters:
-
favorite_name(str) –The name of the Favorite to change.
-
source(FavoriteSettingsSource) –Where the new settings of the Favorite come from: exactly one of favoriteName and toolDefault.
Returns:
create_favorite ¶
create_favorite(
name: str,
source: FavoriteSettingsSource,
folder: None | list[str] = None,
conflict_policy: FavoriteCreationConflictPolicy
| None = None,
) -> CreateFavoriteResult
Creates a Favorite in the given folder from the settings of another Favorite or of the current Opening tool default. conflictPolicy says what happens when the name is taken: fail, skip, overwrite the existing Favorite's settings or create the new one under a free name. Available from Archicad 29.
Parameters:
-
name(str) –The name of the new Favorite.
-
source(FavoriteSettingsSource) – -
folder(None | list[str], default:None) –The folder of the Favorites palette to create the Favorite in, as the folder names from the root down. The folder must exist. Empty or omitted = root.
-
conflict_policy(FavoriteCreationConflictPolicy | None, default:None) –
Returns:
create_favorite_folder ¶
create_favorite_folder(
parent_path: list[str], name: str
) -> FavoriteFolderDetails
Creates a folder in the Favorites palette, in the parent folder given by its path. Returns the new folder. Available from Archicad 29.
Parameters:
-
parent_path(list[str]) –The path of the folder to create the new folder in, in the format GetFavoriteFolders returns: the folder names from the root down. Empty for the root folder.
-
name(str) –The name of the new folder.
Returns:
create_favorites_from_elements ¶
create_favorites_from_elements(
favorites_from_elements: list[FavoriteFromElement],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Create favorites from the given elements.
Parameters:
-
favorites_from_elements(list[FavoriteFromElement]) –
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
delete_favorite_folder ¶
delete_favorite_folder(
path: list[str], recursive: None | bool = None
) -> FavoriteFolderDetails
Deletes a folder of the Favorites palette given by its path. Archicad deletes the folder's Favorites and subfolders with it, so a folder that is not empty is deleted only if recursive is true. The root folder cannot be deleted. Returns the deleted folder. Available from Archicad 29.
Parameters:
-
path(list[str]) –The path of the folder to delete, in the format GetFavoriteFolders returns: the folder names from the root down. The root folder cannot be deleted.
-
recursive(None | bool, default:None) –Archicad deletes a folder together with everything in it: its Favorites and its subfolders with their Favorites. A folder that is not empty is deleted only if this is true. Default: false.
Returns:
delete_favorites ¶
delete_favorites(
favorites: list[str],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Delete existing favorites.
Parameters:
-
favorites(list[str]) –A list of favorite names
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
delete_favorites_with_manager ¶
delete_favorites_with_manager(
favorites: list[FavoriteNameAndFolder],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Deletes the given Favorites through the Favorite manager, each found by name, optionally only in the given folder. One execution result for each. Available from Archicad 29.
Parameters:
-
favorites(list[FavoriteNameAndFolder]) –The Favorites to delete.
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
export_favorites ¶
export_favorites(
path: str,
names: None | list[str] = None,
format: FavoriteExportFormat | None = None,
*,
overwrite: None | bool = None,
) -> SuccessfulExecutionResult
Export the project's Favorites to a .prefs file or folder. From Archicad 29 they can also be exported to a folder of Favorite files (xml format) or to a legacy .prf file (legacyPRF format). Archicad 29 writes a folder with the prefs format even at a .prefs path; ImportFavorites reads it back. With overwrite false an export to a single file refuses to replace an existing file.
Parameters:
-
path(str) –Absolute path on the AC host. With the prefs format: Archicad writes a single file when the path has the extension of its Favorite binary file, otherwise a folder of that name. Archicad 29 creates a folder even at a .prefs path (seen with build 3200, #3087); ImportFavorites with the prefs format reads that folder back, and the legacyPRF format writes a single file. With the xml format: the folder to write the Favorite files to. With the legacyPRF format: the .prf file to write.
-
names(None | list[str], default:None) –Optional subset of Favorites to export. Default: export all.
-
format(FavoriteExportFormat | None, default:None) –prefs (the default) works in every Archicad version. xml exports each Favorite to its own file in the folder, and legacyPRF exports to a Favorites file of earlier Archicad versions; these two require Archicad 29 or newer.
-
overwrite(None | bool, default:None) –Optional, true by default: an existing file is overwritten. false refuses to export when a file or folder already exists at path, and writes nothing. It needs an export to a single file (prefs format with a .prefs path, or legacyPRF format); with an export to a folder it is an error, as the names of the files written there are Archicad's.
Returns:
get_all_favorites ¶
get_all_favorites(
element_type: ElementType | None = None,
) -> list[FavoriteSummary]
Returns every Favorite of the project, or only those of the given element type, with its name and element type. Available from Archicad 29.
Parameters:
-
element_type(ElementType | None, default:None) –Only the Favorites of this element type are returned. Omit it to get every Favorite.
Returns:
-
list[FavoriteSummary]–
get_favorite_contents ¶
get_favorite_contents(
folder_path: None | list[str] = None,
) -> list[ErrorItem | FavoriteContents]
Returns the Favorites of a folder of the Favorites palette and of its subfolders (every Favorite when no folder is given), each with its folder path, classifications, element category values and property values, read through the Favorite manager. Available from Archicad 29.
Parameters:
-
folder_path(None | list[str], default:None) –The folder to read, the folder names from the root of the Favorites palette down. The Favorites of its subfolders are returned too. Omit it or leave it empty for every Favorite.
Returns:
-
list[ErrorItem | FavoriteContents]–The Favorites of the folder and of its subfolders, or an error for a Favorite that could not be read.
get_favorite_defaults ¶
get_favorite_defaults(
favorites: list[str],
) -> list[ErrorItem | FavoriteDefaults]
Reads the element default stored in each given Favorite through the Favorite manager, without applying it or placing an element: the element type, the layer, the element ID, the folder, the library part and GDL parameters, the marker of every element type that has one, and the sub-elements with each of their kinds (Curtain Wall frames and panels, Stair treads and risers, Railing posts and rails, markers ...). Available from Archicad 29.
Parameters:
-
favorites(list[str]) –A list of favorite names
Returns:
-
list[ErrorItem | FavoriteDefaults]–The element default of each given Favorite, in the order of the input, or an error for a Favorite that could not be read.
get_favorite_details ¶
get_favorite_details(
favorites: list[str],
) -> list[ErrorItem | FavoriteDetails]
Returns the classifications, property values and element category values stored in the given favorites, so they can be audited before elements are placed. Each property value comes with its evaluation status and default-value flag; the value itself is only returned when it has been evaluated.
Parameters:
-
favorites(list[str]) –A list of favorite names
Returns:
-
list[ErrorItem | FavoriteDetails]–The details of the given favorites, in the order of the input, or an error for a favorite that could not be read.
get_favorite_folders ¶
get_favorite_folders() -> FavoriteFolderDetails
Returns the folder tree of the Favorites palette from its root folder: the name and path of every folder and the names of the Favorites in it. Available from Archicad 29.
Returns:
get_favorite_preview_image ¶
get_favorite_preview_image(
favorite: str,
image_type: ImageType | None = None,
format: Format | None = None,
width: None | int = None,
height: None | int = None,
) -> str
Returns the preview image of the given favorite.
Parameters:
-
favorite(str) –The name of the favorite.
-
image_type(ImageType | None, default:None) –The type of the preview image. Default is 3D.
-
format(Format | None, default:None) –The image format. Default is png.
-
width(None | int, default:None) –The width of the preview image in pixels. Default is 128.
-
height(None | int, default:None) –The height of the preview image in pixels. Default is 128.
Returns:
-
str–The base64 encoded preview image.
get_favorite_settings ¶
get_favorite_settings(
favorites: list[str],
) -> list[ErrorItem | FavoriteSettings]
Reads the stored settings of the given favorites without applying them or placing an element: the element type, the folder, the library part and GDL parameters, the marker (library part and parameters) of Window and Door favorites, and the sub-elements. A favorite without a marker has no marker field, which is not an error. The other settings of the element (pens, layer, structure, etc.) are not returned.
Parameters:
-
favorites(list[str]) –A list of favorite names
Returns:
-
list[ErrorItem | FavoriteSettings]–The settings of each given Favorite, in the order of the input, or an error for a Favorite that could not be read.
get_favorites_by_type ¶
get_favorites_by_type(
element_type: ElementType,
) -> FavoritesWrapper
Returns a list of the names of all favorites with the given element type
Parameters:
-
element_type(ElementType) –
Returns:
import_favorites ¶
import_favorites(
path: str,
format: FavoriteImportFormat | None = None,
file_names: None | list[str] = None,
target_folder: None | list[str] = None,
import_folders: None | bool = None,
conflict_policy: FavoriteImportConflictPolicy
| None = None,
) -> ImportFavoritesResult
Import Favorites from a .prefs file or folder into the current project. From Archicad 29 they can also be imported from a folder of Favorite files (xml format, all of them or the given fileNames) or from a legacy .prf file (legacyPRF format), with the conflict policies Error, Skip, OverwriteExisting and RenameNew. The answer says whether the import succeeded and names the Favorites it added to the project. In a Teamwork project the Favorites lockable object set must be reserved first (see ReserveLockableObjectSet).
Parameters:
-
path(str) –Absolute path on the AC host. With the prefs format: a Favorites file (.prefs) or folder. With the xml format: the folder of Favorite files, as ExportFavorites writes it. With the legacyPRF format: the .prf file.
-
format(FavoriteImportFormat | None, default:None) – -
file_names(None | list[str], default:None) –Only with the xml format: the names of the Favorite files in the folder to import. Default: every Favorite file of the folder.
-
target_folder(None | list[str], default:None) –Folder hierarchy under which to import. Empty = root. With the xml and legacyPRF formats the folder must exist, and omitting it keeps the folders stored with the Favorites.
-
import_folders(None | bool, default:None) –Only with the prefs format: if true and
pathis a folder, the folder structure is preserved. -
conflict_policy(FavoriteImportConflictPolicy | None, default:None) –
Returns:
move_favorite_folder ¶
move_favorite_folder(
folder: list[str], target_folder: list[str]
) -> list[str]
Moves a folder of the Favorites palette, with its Favorites and subfolders, into another folder. Folders are given as their path of folder names from the root. Returns the new path of the folder. Available from Archicad 29.
Parameters:
-
folder(list[str]) –The folder of the Favorites palette to move, as the folder names from the root down. The root folder cannot be moved.
-
target_folder(list[str]) –The folder to move it into, as the folder names from the root down. Empty = root. It cannot be the moved folder or one of its subfolders.
Returns:
-
list[str]–The new path of the moved folder, as the folder names from the root down.
move_favorites ¶
move_favorites(
favorites: list[str], target_path: list[str]
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Moves Favorites given by their names into a folder of the Favorites palette given by its path. Returns an execution result for each Favorite. Available from Archicad 29.
Parameters:
-
favorites(list[str]) –A list of favorite names
-
target_path(list[str]) –The path of the folder to move the Favorites into, in the format GetFavoriteFolders returns: the folder names from the root down. Empty for the root folder.
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
read_favorites_file ¶
read_favorites_file(path: str) -> list[FavoriteFileEntry]
Read the Favorites of a .prefs file or folder without importing them, returning the name, element type and folder of each. Nothing in the project changes, so the result can be compared with the project's Favorites before ImportFavorites.
Parameters:
-
path(str) –Absolute path on the AC host to a Favorites file (.prefs) or folder.
Returns:
-
list[FavoriteFileEntry]–
rename_favorite_folder ¶
rename_favorite_folder(
path: list[str], new_name: str
) -> FavoriteFolderDetails
Renames a folder of the Favorites palette given by its path. The root folder cannot be renamed. Returns the renamed folder. Available from Archicad 29.
Parameters:
-
path(list[str]) –The path of the folder to rename, in the format GetFavoriteFolders returns: the folder names from the root down. The root folder cannot be renamed.
-
new_name(str) –The new name of the folder.
Returns:
rename_favorites ¶
rename_favorites(
renames: list[FavoriteRename],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Rename existing favorites.
Parameters:
-
renames(list[FavoriteRename]) –
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
search_favorites ¶
search_favorites(
query: None | str = None,
element_type: ElementType | None = None,
limit: None | int = None,
) -> list[FavoriteSummary]
Searches project favorites by keyword (matching favorite name or folder) and/or element type.
Parameters:
-
query(None | str, default:None) –Optional case-insensitive substring to search in favorite name or folder hierarchy.
-
element_type(ElementType | None, default:None) –Optional filter by element type. If omitted, searches across all element types.
-
limit(None | int, default:None) –Maximum number of matching favorites to return.
Returns:
-
list[FavoriteSummary]–The matching Favorites, each with its element type and folder.
update_favorites_from_elements ¶
update_favorites_from_elements(
favorites_from_elements: list[
FavoritesFromElementUpdate
],
) -> list[
FailedExecutionResult | SuccessfulExecutionResult
]
Update existing favorites from the given elements.
Parameters:
-
favorites_from_elements(list[FavoritesFromElementUpdate]) –
Returns:
-
list[FailedExecutionResult | SuccessfulExecutionResult]–A list of execution results.
Related types¶
These include the parameter and result models used inside the client. The command signatures above show what to pass and what is returned.
ApplyFavoriteToToolDefaultParametersApplyFavoriteToToolDefaultResultApplyFavoritesToElementDefaultsParametersApplyFavoritesToElementDefaultsResultApplyFavoritesToElementsParametersApplyFavoritesToElementsResultChangeFavoriteParametersCreateFavoriteFolderParametersCreateFavoriteFolderResultCreateFavoriteParametersCreateFavoriteResultCreateFavoritesFromElementsParametersCreateFavoritesFromElementsResultDeleteFavoriteFolderParametersDeleteFavoriteFolderResultDeleteFavoritesParametersDeleteFavoritesResultDeleteFavoritesWithManagerParametersDeleteFavoritesWithManagerResultExportFavoritesParametersGetAllFavoritesParametersGetAllFavoritesResultGetFavoriteContentsParametersGetFavoriteContentsResultGetFavoriteDefaultsParametersGetFavoriteDefaultsResultGetFavoriteDetailsParametersGetFavoriteDetailsResultGetFavoriteFoldersResultGetFavoritePreviewImageParametersGetFavoritePreviewImageResultGetFavoriteSettingsParametersGetFavoriteSettingsResultGetFavoritesByTypeParametersImportFavoritesParametersImportFavoritesResultMoveFavoriteFolderParametersMoveFavoriteFolderResultMoveFavoritesParametersMoveFavoritesResultReadFavoritesFileParametersReadFavoritesFileResultRenameFavoriteFolderParametersRenameFavoriteFolderResultRenameFavoritesParametersRenameFavoritesResultSearchFavoritesParametersSearchFavoritesResultUpdateFavoritesFromElementsParametersUpdateFavoritesFromElementsResultElementIdArrayItemElementTypeElementTypeFloorLayerFilterErrorItemFailedExecutionResultFavoriteContentsFavoriteCreationConflictPolicyFavoriteDefaultsFavoriteDetailsFavoriteExportFormatFavoriteFileEntryFavoriteFolderDetailsFavoriteFromElementFavoriteImportConflictPolicyFavoriteImportFormatFavoriteKeepFieldFavoriteNameAndFolderFavoriteRenameFavoriteSettingGroupFavoriteSettingsFavoriteSettingsSourceFavoriteSummaryFavoriteToApplyFavoritesFromElementUpdateFavoritesWrapperFormatImageTypeSuccessfulExecutionResult