Create rooms from walls

Hi everyone !

I would like to create all my rooms in my Revit model for each level with dynamo.
I was thinking to use the node : Room.ByLocation

But the question is : How can I get information about the room location ?

I’m thinking to use the walls inner perimeter.

But, to get the walls inner perimeter I intersect the geormetry of the walls with those of the room.

So I have no idea how to get the information ?

Thank you for your help :slight_smile:

You can get that information from a Plan Circuit. I modified a bit of code from Julien Benoit a while ago to do this for rooms and spaces.

#python nodes in dynamo 0.9
#originally proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/
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])
pointList = []
#rooms=UnwrapElement(IN[2])

phases=doc.Phases
# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for level in levels:
	PT=doc.get_PlanTopology(level)
	circuits=PT.Circuits
	a=circuits.Size
	points=[]
	for p in circuits:
		points.append(p.GetPointInside())
	pointList.append(points)			
# End Transaction
TransactionManager.Instance.TransactionTaskDone()
OUT =pointList

Each Level input should return a list of available room/space Points. From there, you should have no problem creating rooms by Point and Level.

3 Likes

Thank you so much !! :slight_smile:

But, I can’t use the results.


I don’t know how can I used it.

(I tried pt_deconstr (pt.X), I tried the node : string from array and String.SpecifyPlaces)

just a guess, but i think you need an actual XYZ point, not what look like strings

Yes, I’m looking for a point ,but how can I do it ?

I don’t remember if it returns the coordinates as a string or a Revit XYZ. Either, way you need to convert it to a point. I think I have another Python script that will do this for you.

Assuming those are strings, you’ll need to parse out the numbers. Remove the parenthesis and the comma, split at the space, convert string to number. This gives you X and Y (I assume) and you can get Z from the level. Then create an XYZ point.

1 Like

It looks like the coordinates are Revit UVs. You just need to use this method:
http://www.revitapidocs.com/2018/28262c8c-d18a-338c-eb17-f406438949d8.htm

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

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

TransactionManager.Instance.EnsureInTransaction(doc)

for points, level in zip(plancircuits,levels):
	for p in points:
		newRoom = doc.Create.NewRoom(level,p)
		newRoomList.append(newRoom)
					
TransactionManager.Instance.TransactionTaskDone()
OUT = newRoomList
2 Likes

What’s that first Python Script node doing? The second, I assume, is from @Nick_Boyts post.

The first node removes duplicate levels from the element.level node.