Change Basement of rooms , how?

Hello Dynos,

i found to this topic some kind of solution in C#. How can i set a new basement for rooms.

so when i do it manualy:
1.) delete room
2.) place the deleted room it in the right view → Level
3.) height correct

Does anyone have a workflow in dynamo?

i struggle also with Revit2024 Dynamo:

#test

import sys
import clr


clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import ISelectionFilter, ObjectType, Selection

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
selection = uidoc.Selection #type: Selection

# 🛒 classes
class ISelectionFilter_Classes(ISelectionFilter):
    def __init__(self, allowed_types):
        """ ISelectionFilter made to filter with types
        :param allowed_types: list of allowed Types"""
        self.allowed_types = allowed_types

    def AllowElement(self, element):
        if type(element) in self.allowed_types:
            return True

# 0️⃣ PickElementsByRectangle
selected_elements = [doc.GetElement(e_id) for e_id in selection.GetElementIds()]
selected_rooms = [el for el in selected_elements if type == Room]

if not selected_rooms:
    filter_types = ISelectionFilter_Classes([Room])
    ref_picked_rooms = selection.PickObjects(ObjectType.Element, filter_types)
    selected_rooms = [doc.GetElement(ref) for ref in ref_picked_rooms]

if not selected_rooms:
    print("Please select a Room")
    import sys
    sys.exit()

currentBasement = [p.get_Parameter(BuiltInParameter.ROOM_LEVEL_ID).AsElementId() for p in selected_rooms]

OUT = selected_elements, currentBasement

it can`t see ISelectionFilter
grafik

KR

Andreas

Interfaces can be difficult in Python 3 as there are known issues - see discussion here

2 Likes

Why do you need the custom selection filter? Dynamo 2.19 (Revit 2024) has a Select Model Elements by Category node that does what I think you’re looking for. Use it to select your Rooms and then choose a new Level from a dropdown. Then you just have to automate the placement of the rooms onto their new level.