Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#PackageMEPover
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
ref_level = UnwrapElement(IN[1])
listout = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i,x in enumerate(element):
ref_levelid = ref_level.Id
#familyinstances
try:
object_param_level = x.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM)
object_level = doc.GetElement(object_param_level.AsElementId())
object_param_offset = x.get_Parameter(BuiltInParameter.INSTANCE_FREE_HOST_OFFSET_PARAM)
object_newoffset = object_param_offset.AsDouble() + object_level.Elevation - ref_level.Elevation
object_param_level.Set(ref_levelid)
object_param_offset.Set(object_newoffset)
listout.append(x)
#system families
except:
try:
object_param_level = x.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM)
object_param_level.Set(ref_levelid)
listout.append(x)
except:
pass
TransactionManager.Instance.TransactionTaskDone()
OUT = listout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment