Room centering location



Hi all,

I know package Modelical has the node called “room and tag location centering”
but i did change the phase name as shown in the image like “XX_EXIST” and “XX_NEW” then the script doesn’t work. it will work when there isn’t “XX_” as prefix infront. Does anyone know where to fix in the python script?


hi @dylanpeng, you can try this;


# dynamo version - 1.3.x, 2,x,x

import clr

import System,Revit
from Autodesk.DesignScript.Geometry import (Geometry,
Point as pt)
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

elems = IN[0];

# make list
if not isinstance(elems,list):
	elems = UnwrapElement([elem])
	elems = UnwrapElement(elems)

# output
res = []
# start transaction

# loop elements
for e in elems:
	# level elevation - unit millimeter 
	elevation = e.Level.Elevation * 304.8
	# get geo-objects of the element
	geoelem = e.GetGeometryObjectFromReference(Reference(e))
	# get enumerator to loop geo-objects
	geoobj = geoelem.GetEnumerator()
	# loop geo-objector
	for obj in geoobj:
		# convert to dynamo type
		room_geometry = obj.ToProtoType()
		# get the centroid of the element
		point = room_geometry.Centroid()
		# create location point with level elevation
		center = pt.ByCoordinates(point.X,point.Y,elevation)
		# current element location
		current = e.Location.Point
		# point convert to revit and minus from current location
		newloc = center.ToXyz() - current
		# move to new location

# transaction done

# output
OUT = elems


Hi Jean,

Thank you very much. It works for " XX_ " but when I start to change the prefix say AB_, it dosent work again.


I couldn’t find in your python script which part relate the prefix.


hi @dylanpeng, the underlying issue is room status. You can try this way again.


Hi Jean,

it works! fantastic! Is it possible to do the same thing for area?


Was trying to fix something similar, this is working for me: