New rooms from Walls

Good afternoon everyone,

I am trying to create all rooms in a level with a Python Code and it is not working. I am using Revit 2021.1 and the Revit API Docs Method NewRooms2(Level,Phase).

The code should create three rooms, as I have three areas delimeted by walls. However, it only creates one room adn it is not inside any of the perimeters of the walls

Any idea on how to create all rooms delimited by walls at the same time? I attach some images and the code.

Many thanks in advance.


# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


levels = UnwrapElement(IN[0])
phase = UnwrapElement(IN[1])
newRoomList = []

TransactionManager.Instance.EnsureInTransaction(doc)

newRoom = doc.Create.NewRooms2(levels,phase)
newRoomList.append(newRoom)
					
TransactionManager.Instance.TransactionTaskDone()
OUT = newRoomList

image
image

@arantza ,

is autocreation not the fasted way?

image

KR

Andreas

Hi Andreas,

Yes, probably. However, I’d like to do it with dynamo+python, I’m doing a course about it and I have to do a final project and I thought it would be nice to create all rooms and after complete their parameter everything with dynamo and/or python. I thought about python because of this.

Thanks
Arantza

Hello @arantza
can you share the rvt files ? walls are in a link model ?

Hi c.poupin,
I attach the revit file, as you will see there are no links.

Thanks!
Rooms.rvt (7.2 MB)

Hi,

your code works fine, for the extra room there are non-structural walls in your model

2 Likes

Many thanks!! c.poupin I didn’t notice that I didn’t have correctly selected the discipline

Arantza

2 Likes