Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Warnings package

Subpackages

Submodules

duHast.Revit.Warnings.solver module

Warnings solver utility class.

class duHast.Revit.Warnings.solver.RevitWarningsSolver

Bases: Base

Constructor: assigns the default element filter (pass all)

default_filter_return_all(doc, element_id)

Default filter for elements past into solver…returns True for any element past in.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • element_id (Autodesk.Revit.DB.ElementId) – The id of the element to be checked.

Returns:

True always.

Return type:

bool

solver_room_tag_to_room = RevitWarningsSolverRoomTagToRoom(filter_name='Room tag outside of room.', transaction_manager=<function in_transaction>, callback=None)

default solver classes

solver_same_mark = RevitWarningsSolverDuplicateMark(filter=<function RevitWarningsSolver.default_filter_return_all>, filter_values=[], filter_name='Duplicate mark value.', callback=None)
solver_room_sep_lines = RevitWarningsSolverRoomSepLinesOverlap(filter_name='Room separation lines overlap.', solve_by_lengthening_curves=True, transaction_manager=<function in_transaction>, group_id=-1, callback=None)
solver_area_sep_lines = RevitWarningsSolverAreaSepLinesOverlap(filter_name='Area separation lines overlap.', solve_by_lengthening_curves=True, transaction_manager=<function in_transaction>, group_id=-1, callback=None)
AVAILABLE_SOLVERS = {'374396c0-984d-4f72-a081-30ab7dacb66d': RevitWarningsSolverRoomSepLinesOverlap(filter_name='Room separation lines overlap.', solve_by_lengthening_curves=True, transaction_manager=<function in_transaction>, group_id=-1, callback=None), '4f0bba25-e17f-480a-a763-d97d184be18a': RevitWarningsSolverRoomTagToRoom(filter_name='Room tag outside of room.', transaction_manager=<function in_transaction>, callback=None), '6891f0e6-5858-4e2f-bb34-801e0b87f60d': RevitWarningsSolverAreaSepLinesOverlap(filter_name='Area separation lines overlap.', solve_by_lengthening_curves=True, transaction_manager=<function in_transaction>, group_id=-1, callback=None), '6e1efefe-c8e0-483d-8482-150b9f1da21a': RevitWarningsSolverDuplicateMark(filter=<function RevitWarningsSolver.default_filter_return_all>, filter_values=[], filter_name='Duplicate mark value.', callback=None)}

solver dictionary of available warning solvers by guid

set_same_mark_filter_and_filter_solver(same_mark_filter_solver)

Method allowing to override the default filter function

Parameters:

same_mark_filter_solver (func(document, elementId, list of filter values)) – A function to filter elements in warnings by

solve_warnings(doc)

Attempts to solve some warning in a revit model using available warnings solver.

It will get all warnings in model, filter them by available solver GUIDs and finally will attempt to solve the warnings matched up with a solver.

Parameters:

doc (Autodesk.Revit.DB.Document) – Current Revit model document.

Returns:

Result class instance.

  • .status True if all warnings could be solved. Otherwise False.

  • .message will contain all messages solver returned.

Return type:

Result

duHast.Revit.Warnings.solver_area_separation_lines_overlap module

area separation lines solver class.

Currently address’ area separation lines overlapping with other area separation lines only.

class duHast.Revit.Warnings.solver_area_separation_lines_overlap.RevitWarningsSolverAreaSepLinesOverlap(solve_by_lengthening_curves=True, group_id=-1, transaction_manager=<function in_transaction>, callback=None)

Bases: Base

A solver that addresses overlapping area separation lines in a Revit model. It can delete or modify these lines to resolve the overlap issue.

Example Usage: solver = RevitWarningsSolverAreaSepLinesOverlap() result = solver.solve_warnings(doc, warnings) print(result.status) print(result.message)

Main functionalities: - Solving overlapping area separation lines by deleting or modifying them. - Ignoring area separation lines that overlap when they are in group instances.

Class constructor.

Parameters:
  • solve_by_lengthening_curves (bool, optional) – Whether to solve the overlapping curves by lengthening or shortening. Defaults to True.

  • group_id (int, optional) – The group ID that the curves need to belong to for processing. Defaults to -1.

  • transaction_manager (function, optional) – The transaction manager function used to perform the modifications. Defaults to in_transaction.

  • callback (function, optional) – An optional callback function.

GUID = '6891f0e6-5858-4e2f-bb34-801e0b87f60d'

guid identifying this specific warning

solve_warnings(doc, warnings)

Solver addressing overlapping area separation lines.

  • will ignore area separation lines overlapping when in different group instances.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • warnings (Autodesk.Revit.DB.FailureMessage) – List of warnings to be solved.

Returns:

Result class instance.

  • .status True if all area separation lines could be deleted / modified without an exception. Otherwise False.

  • .message will be ‘moved tag to area xyz’

Return type:

Result

duHast.Revit.Warnings.solver_duplicate_mark module

Duplicate mark warnings solver class.

class duHast.Revit.Warnings.solver_duplicate_mark.RevitWarningsSolverDuplicateMark(filter_func, filter_values=None, callback=None)

Bases: Base

Constructor: this solver takes two arguments: a filter function and a list of values to filter by

Parameters:
  • filter_func (func(document, elementId, list of filter values)) – A function to filter elements in warnings by

  • filter_values (list, optional) – A list of filter values, defaults to []

GUID = '6e1efefe-c8e0-483d-8482-150b9f1da21a'

guid identifying this specific warning

IGNORED_WARNINGS = ['Type Mark']
solve_warnings(doc, warnings)

Solver setting element mark to nothing, provided it passes the filter.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • warnings (Autodesk.Revit.DB.FailureMessage) – List of warnings to be solved.

Returns:

Result class instance.

  • .status True if all duplicate mark warnings could be solved. Otherwise False.

  • .message will contain stats in format parameter value set to ‘’

Return type:

Result

duHast.Revit.Warnings.solver_room_separation_lines_overlap module

Room separation lines solver class.

Currently address’ room separation lines overlapping with other room separation lines only.

class duHast.Revit.Warnings.solver_room_separation_lines_overlap.RevitWarningsSolverRoomSepLinesOverlap(solve_by_lengthening_curves=True, group_id=-1, transaction_manager=<function in_transaction>, callback=None)

Bases: Base

A solver that addresses overlapping room separation lines in a Revit model. It can delete or modify these lines to resolve the overlap issue.

Example Usage: solver = RevitWarningsSolverRoomSepLinesOverlap() result = solver.solve_warnings(doc, warnings) print(result.status) print(result.message)

Main functionalities: - Solving overlapping room separation lines by deleting or modifying them. - Ignoring room separation lines that overlap when they are in group instances.

Class constructor.

param solve_by_lengthening_curves: Whether to solve the overlapping curves by lengthening or shortening. Defaults to True. :type solve_by_lengthening_curves: bool, optional :param group_id: The group ID that the curves need to belong to for processing. Defaults to -1. :type group_id: int, optional :param transaction_manager: The transaction manager function used to perform the modifications. Defaults to in_transaction. :type transaction_manager: function, optional :param callback: An optional callback function. :type callback: function, optional

GUID = '374396c0-984d-4f72-a081-30ab7dacb66d'

guid identifying this specific warning

solve_warnings(doc, warnings)

Solver addressing overlapping room separation lines.

  • will ignore room separation lines overlapping when in different groups.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • warnings (Autodesk.Revit.DB.FailureMessage) – List of warnings to be solved.

Returns:

Result class instance.

  • .status True if all room separation lines could be deleted / modified without an exception. Otherwise False.

  • .message will be ‘moved tag to room xyz’

Return type:

Result

duHast.Revit.Warnings.solver_room_tag_to_room module

Room tag not in room warnings solver class.

class duHast.Revit.Warnings.solver_room_tag_to_room.RevitWarningsSolverRoomTagToRoom(transaction_manager=<function in_transaction>, callback=None)

Bases: Base

Empty constructor this solver does not take any further arguments.

GUID = '4f0bba25-e17f-480a-a763-d97d184be18a'

guid identifying this specific warning

solve_warnings(doc, warnings)

Solver moving room tags to room location point.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • warnings (Autodesk.Revit.DB.FailureMessage) – List of warnings to be solved.

Returns:

Result class instance.

  • .status True if all room tags within warnings could be moved to room location point. Otherwise False.

  • .message will be ‘moved tag to room xyz’

Return type:

Result

duHast.Revit.Warnings.warning_guids module

This module contains a warning guids of specific Revit warnings.

duHast.Revit.Warnings.warnings module

This module contains a number of helper functions relating to Revit warnings.

duHast.Revit.Warnings.warnings.get_warnings(doc)

Returns a list of warnings from the model

Parameters:

doc (Autodesk.Revit.DB.Document) – Current Revit model document.

Returns:

List of all failure messages in model.

Return type:

list of Autodesk.Revit.DB.FailureMessage

duHast.Revit.Warnings.warnings.get_warnings_by_guid(doc, guid)

Returns all failure message objects where failure definition has matching GUID

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • guid (Autodesk.Revit.DB.Guid) – Filter: Identifying a specific failure of which the corresponding messages are to be returned.

Returns:

list of all failure messages with matching guid

Return type:

list of Autodesk.Revit.DB.FailureMessage

duHast.Revit.Warnings.warnings.get_unique_warnings_elements_by_guid(doc, guid)

Returns a list of element ids of all warnings with a specific guid

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • guid (string) – Filter: Identifying a specific failure of which the corresponding messages are to be returned.

Returns:

List of element ids of all warnings with a specific guid

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Warnings.warnings.get_single_warnings_elements_by_guid(doc, guid)

Returns a list of element ids of all warnings with a specific guid Returns the first failing element in each warning only!

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • guid (string) – Filter: Identifying a specific failure of which the corresponding messages are to be returned.

Returns:

List of element ids of all warnings with a specific guid

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Warnings.warnings.get_warnings_grouped_by_relation(doc, guid)

Returns a dictionary of warnings where all warnings specified by guid related to each other are grouped together. Key will be the element with the lowest element id, value will be a list of element ids, in ascending order, of all warnings in the group (including the key!)

Note: Revit must report exactly two elements per warning for this to work

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • guid (Autodesk.Revit.DB.Guid) – Filter: Identifying a specific failure of which the corresponding messages are to be returned.

Returns:

Dictionary of warnings grouped by element id

Return type:

dict

Module contents