Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Rooms package

Subpackages

Submodules

duHast.Revit.Rooms.room_common_parameters module

Revit API utility functions for Rooms.

duHast.Revit.Rooms.room_common_parameters.get_room_number(room)

Get the room number of the room :param room: The room to get the number of :type room: Room :return: The room number of the room :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_room_name(room)

Get the room name of the room :param room: The room to get the name of :type room: Room :return: The room name of the room :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_room_phase(rvt_doc, room)

Get the phase of the room :param rvt_doc: The document to get the room from :type rvt_doc: Document :param room: The room to get the phase of :type room: Room :return: The phase of the room :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_room_phase_object(rvt_doc, room)

Get the revit phase object of the room :param rvt_doc: The document to get the room from :type rvt_doc: Document :param room: The room to get the phase of :type room: Room :return: The phase of the room :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_room_level(rvt_doc, room)

Get the phase of the room :param rvt_doc: The document to get the room from :type rvt_doc: Document :param room: The room to get the phase of :type room: Room :return: The phase of the room :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_room_num_variations(room)

Get a list of variations of room number e.g. 1.01, 101, 1-01 :param room: The room to get the number of :type room: Room :return: The list of variations of room number :rtype: list

duHast.Revit.Rooms.room_common_parameters.get_room_num_name_comb(room)

Get a combination of room number and name in the format: ‘101 - Room Name’ :param room: The room to get the number and name of :type room: Room :return: The combination of room number and name :rtype: str

duHast.Revit.Rooms.room_common_parameters.get_rooms_in_view(document, targ_view)

Get all rooms in the view. This avoids using the FilteredElementCollector overload that takes a view id as an argument as this is has to generate graphics for all elements in the view which is very slow. :param document: The document to get the rooms from :type document: Document :param targ_view: The view to get the rooms from :type targ_view: View :return: The rooms in the view :rtype: list

duHast.Revit.Rooms.room_common_parameters.get_room_from_element(phase_dictionary, elem)

Get the room associated with the element. This should be updated by Revit as the element moves :param phase_dictionary: The dictionary of phases names to phase elements :type phase_dictionary: dict :param elem: The element to get the room of :type elem: Element :return: The room associated with the element :rtype: Room

duHast.Revit.Rooms.room_common_parameters.check_element_is_in_room(phase_dictionary, elem, room_to_check)

Check if the element is in the room :param phase_dictionary: The dictionary of phases names to phase elements :type phase_dictionary: dict :param el: The element to check :type el: Element :param room_to_check: The room to check if the element is in :type room_to_check: Room :return: True if the element is in the room, False otherwise :rtype: bool

duHast.Revit.Rooms.room_common_parameters.get_room_from_selection(rvt_doc, id_list)

Get the first Room from a selection of element ids :param rvt_doc: The document to get the room from :type rvt_doc: Document :param id_list: The list of element ids to check :type id_list: list :return: The room from the selection :rtype: Room

duHast.Revit.Rooms.room_common_parameters.check_room_on_view_level(rvt_doc, room, view)

Check if the room is on the same level as the view :param rvt_doc: The document to get the room from :type rvt_doc: Document :param room: The room to check :type room: Room :param view: The view to check :type view: View :return: True if the room is on the same level as the view, False otherwise :rtype: bool

duHast.Revit.Rooms.room_common_parameters.check_rm_pt_extents(rvt_doc, room_list, target_view, target_view_crop_bx_pts)

Check if all the points from the room boundary segments are within a view crop box for a list of rooms :param rvt_doc: The document to get the room from :type rvt_doc: Document :param room_list: The list of rooms to check :type room_list: list :param target_view: The view to check :type target_view: View :param target_view_crop_bx_pts: The points of the view crop box curves :type target_view_crop_bx_pts: list :return: The rooms that are entirely within the view crop box :rtype: list

duHast.Revit.Rooms.room_common_parameters.check_rm_loc_point(room_list, target_view_crop_bx_pts)

Check if the location crosshairs of a room is within a view crop box for a list of rooms :param room_list: The list of rooms to check :type room_list: list :param target_view_crop_bx_pts: The points of the view crop box curves :type target_view_crop_bx_pts: list :return: The rooms that have their location point within the view crop box :rtype: list

duHast.Revit.Rooms.room_common_parameters.get_only_entire_rooms(rvt_doc, rm_list, view, check_rm_edges=False)

Get only the rooms that are entirely within the view crop box :param rvt_doc: The document to get the room from :type rvt_doc: Document :param rm_list: The list of rooms to check :type rm_list: list :param view: The view to check :type view: View :param check_rm_edges: True: Check if the entire room boundary segments are in the view crop box False: Check if the location crosshair is in the view crop box :type check_rm_edges: bool :return: The rooms that are entirely within the view crop box :rtype: list

duHast.Revit.Rooms.room_common_parameters.get_all_rooms_in_plan_views(rvt_doc, view_list)

Get all rooms in the plan views :param rvt_doc: The document to get the room from :type rvt_doc: Document :param view_list: The list of views to check :type view_list: list :return: The rooms in the plan views :rtype: list

duHast.Revit.Rooms.room_common_parameters.get_rooms_from_sheet_obj_list(rvt_doc, sheet_obj_list)

Get all rooms from the sheet object list :param rvt_doc: The document to get the room from :type rvt_doc: Document :param sheet_obj_list: The list of ViewSheetBaseObject objects to check :type sheet_obj_list: list :return: The rooms from the sheet object list :rtype: list

duHast.Revit.Rooms.room_lines module

Revit API utility functions for Room separation lines.

duHast.Revit.Rooms.room_lines.get_room_separation_lines(doc)

Get all room separation lines in the document.

Parameters:

doc (Document) – The Revit document.

Returns:

A collector containing room separation lines.

Return type:

FilteredElementCollector

duHast.Revit.Rooms.room_lines.get_all_room_separation_lines_ids_with_warnings(doc)

Returns the room separation line ids which have warnings associated with them.

Parameters:

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

Returns:

List of element ids

Return type:

[Autodesk.Revit.DB.ElementId]

duHast.Revit.Rooms.room_lines.get_all_room_separation_lines_ids_without_warnings(doc)

returns the ids of all room separation lines in the model without any wanring associated with them.

Parameters:

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

Returns:

List of element ids

Return type:

[Autodesk.Revit.DB.ElementId]

duHast.Revit.Rooms.room_lines.get_room_separation_lines_by_level_name(doc, level_name)

Get all room separation lines in the document on a specific level by name.

Parameters:
  • doc (Document) – The Revit document.

  • level_name (str) – The name of the level.

Returns:

A list of room separation lines on the specified level.

Return type:

list

duHast.Revit.Rooms.room_lines.get_room_separation_lines_by_level_names(doc)

Get all room separation lines in the document sorted by level name.

Parameters:

doc (Document) – The Revit document.

Returns:

A dictionary containing room separation lines sorted by level name.

Return type:

dict

duHast.Revit.Rooms.room_lines.sort_room_separation_line_by_phase_created(room_separation_lines)

Sorts the room separation lines by phase created id

Parameters:

room_separation_lines – list of room separation lines

:type room_separation_lines:list

Returns:

A dictionary of room separation lines, where key is the phase created id, and values are the associated room separation lines

Return type:

{ElementId:[ModelLine]}

duHast.Revit.Rooms.room_lines.filter_room_separation_lines_by_phase_created(doc, room_separation_lines, phase_created_name)

Filter room separation lines by phase created.

Parameters:
  • doc (Document) – The Revit document.

  • phase_created_name (str) – The phase name of the phase the room separation lines was created in.

Returns:

A list of room separation lines filtered by phase created.

Return type:

list

duHast.Revit.Rooms.room_lines.filter_room_separation_lines_by_phase_demolished(doc, room_separation_lines, phase_demolished_name)

Filter room separation lines by phase demolished.

Parameters:
  • doc (Document) – The Revit document.

  • phase_demolished_name (str) – The phase name of the phase the room separation lines was demolished in.

Returns:

A list of room separation lines filtered by phase demoplished.

Return type:

list

duHast.Revit.Rooms.room_lines.filter_room_separation_lines_by_phase_created_older_than_upper_bound_phase(doc, room_separation_lines, upper_bound_phase_id)

Filter room separation lines by phase created. Phase created value must be a phase equal to or older than the upper bound phase id. If upper bound phase Id is and ElementId.InvalidElementId the list will be returned unchanged.

Parameters:
  • doc (Document) – The Revit document.

  • room_separation_lines ([]) – A list of room separation lines

  • upper_bound_phase_id (Autodesk.Revit.ElementId) – the id of the phase to be used as upper bound

Returns:

A list of room separation lines filtered by phase created.

Return type:

list

duHast.Revit.Rooms.room_lines.filter_room_separation_lines_by_level_id(room_separation_lines, level_id)

Filter room separation lines by level id its placed on.

Parameters:
  • room_separation_lines ([]) – A list of room separation lines

  • level_id (Autodesk.Revit.ElementId) – The id of he level to be filtered by.

Returns:

A list of room separation lines filtered by level placed on.

Return type:

list

duHast.Revit.Rooms.room_tags module

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

duHast.Revit.Rooms.room_tags.move_tag_to_room(doc, tag_id, transaction_manager=<function in_transaction>)

Moves a room tag to the associated rooms location point. This will

  • un-pin the tag

  • disable any leader

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

  • tag_id (Autodesk.Revit.DB.ElementId) – The element id of the tag to be moved to the room.

  • transaction_manager ((function)) – The transaction manager used to perform the modifications.

Returns:

Result class instance.

  • Tag moving status returned in result.status. False if an exception occurred, otherwise True.

  • result.message will contain the name and number of the room.

On exception (handled by optimizer itself!):

  • result.status (bool) will be False.

  • result.message will contain the name and number of the room and the exception message.

Return type:

Result

duHast.Revit.Rooms.rooms module

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

duHast.Revit.Rooms.rooms.get_all_rooms(doc)

Gets a list of rooms from the model using built in category.

Note: This appears to be slightly faster than using a RoomFilter.

Parameters:

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

Returns:

All the rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

duHast.Revit.Rooms.rooms.get_all_rooms_as_collector(doc)

Gets a list of rooms from the model using built in category.

Note: This appears to be slightly faster than using a RoomFilter.

Parameters:

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

Returns:

All the rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

duHast.Revit.Rooms.rooms.get_unplaced_rooms(doc)

Gets a list of unplaced rooms from the model.

Parameters:

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

Returns:

All the unplaced rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

duHast.Revit.Rooms.rooms.get_not_enclosed_rooms(doc)

Gets a list of not enclosed rooms from the model.

Parameters:

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

Returns:

All the unenclosed rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

duHast.Revit.Rooms.rooms.get_redundant_rooms(doc)

Gets a list of redundant rooms from the model.

Parameters:

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

Returns:

All the redundant rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

duHast.Revit.Rooms.rooms.get_all_placed_rooms(doc)

Gets a list of all placed rooms from the model.

Placed criteria is Location is not null and Area > 0.0m2

Parameters:

doc (Autodesk.Revit.DB.Document) – Revit model document to search.

Returns:

All the placed rooms in the model as a list.

Return type:

List Autodesk.Revit.DB.Architecture.Room

Module contents