Hello!
Maybe, I create this topic not first, but I’ve a problem: I need to create spaces by architects rooms, and I tired) I finded a dynamo script (whith Python), but it’s work only on small project. As example: if you have 2 linked files (AR) in HVAQ’s model and AR’s models insert in consolidated file by shared coordinates - this script doesn’t work. My python is not so good to create code, but I can find a problem in existing code. Author of this script used coordinates XYZ to finded rooms, but all of linked files (AR model) create at point 0.0.0 (I mean intersection point of axis A and 1).
Maybe someone have working script??? Or someone can help me with this code??? Please, help!!!
import clr
from math import *
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
from System.Collections.Generic import *
links = FilteredElementCollector(doc).OfClass(Autodesk.Revit.DB.RevitLinkInstance).ToElements()
linkdocs = []
for i in links:
linkdocs.append(i.GetLinkDocument())
linkrooms = []
for linkdoc in linkdocs:
try:
linkrooms.append(FilteredElementCollector(linkdoc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements())
except:
0
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
old_spaces = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_MEPSpaces).WhereElementIsNotElementType().ToElements()
rooms=[]
for g_rooms in linkrooms:
for room in g_rooms:
if room.Area>0:
TransactionManager.Instance.EnsureInTransaction(doc)
list=[]
message=[]
for room in rooms:
pt = room.Location.Point
i=0
for space in old_spaces:
y = space.IsPointInSpace(XYZ(pt.X,pt.Y,pt.Z+1))
if y:
i=1
message.append(y)
if i==0:
uv = UV(pt.X,pt.Y)
elev = round(room.Level.Elevation)
level2 = None
for level in levels:
elev2 = round(level.Elevation)
if elev==elev2:
level2=level
if level2 is not None:
name = room.get_Parameter(BuiltInParameter.ROOM_NAME).AsString()
number = room.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString()
height = room.get_Parameter(BuiltInParameter.ROOM_UPPER_OFFSET).AsDouble()
space = doc.Create.NewSpace(level2,uv)
space.get_Parameter(BuiltInParameter.ROOM_NAME).Set(name)
space.get_Parameter(BuiltInParameter.ROOM_NUMBER).Set(number)
space.get_Parameter(BuiltInParameter.ROOM_UPPER_OFFSET).Set(height)
list.append(space)
TransactionManager.Instance.TransactionTaskDone()
OUT = list
Code.txt (2.4 KB)
Maybe we inserted models not by the rules?
it is working
you are missing the node Space.byPoint
Hi,
Look at this topic to transform the “origin” coordinates in shared coordinates.
I was show you, that node “Room.Location” gives to us points not in “true” model
yes, i see it now, sorry
It’s hard to know without your revit files.
I think the internal origin must be different in the host and linked Revit file.
You can try this :
Get locations of rooms.dyn (21.6 KB)
You can you upload your models with a third party sharing site such as onedrive, google drive, dropbox, wetransfer…
For which model do you want to create spaces AR_1 or AR_2 ? Because your rooms come from the AR2 model.
I want to create spaces in all models. In AR_1 it’s creating - I upload it first (base point to base point). Then, I gives coordinates from AR_1, inserted AR_2 and tranfer to this model coordinates.
https://drive.google.com/open?id=1_vXxCNJYlMbNWnw1XpKe_r5FhzSSdNhb
AR_1 model is missing.
Oh, I’m sorry. Try it now
Alban, who created node “springs.collector.linkedinstanselements”?) I can’t find it
It’s in package Springs 







