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?
# dynamo version - 1.3.x, 2,x,x
import clr
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference("RevitNodes")
import System,Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
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])
else:
elems = UnwrapElement(elems)
# output
res = []
# start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# 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
e.Location.Move(newloc)
# transaction done
TransactionManager.Instance.TransactionTaskDone()
# output
OUT = elems
i love this ! always try to develop out of basic nodes in dynamo even tho it could be a little more complex is my goal. since i am not so good with writing python … yet. Thanks
OH MY BUDDHA ! It works ! thank you! somehow this afternoon, i tried to connect room elements there it didnt move! so happy ! thank you very much for your advice