Hi All, I want to place an Air Terminal in a Mechanical Project using a wall placed in a Revit Link as Host with Dynamo.
I tried using “FamilyInstance.ByFace” node but this node returns to me an error: “Reference from different document”. I also tried using RevitAPI and “NewFamilyInstance” methods but the script returns the same error.
Is there a method in RevitAPI or a node in dynamo that allows me to complete this task?
Thanks for the support!
What file type is it that youre linking in?
Can you do it in Revit UI without Copy/Monitor thing?
Hi, I link an Architectural model, and I want RevitLinkInstance as Family Host. The Air terminal needs to have RevitLInkInstance as Host, in particular a ceiling in the linked Architectural model, in order to update his position if the ceiling moves.
Hi, I could change Host in Revit selecting another element, but I want to automate the creation of Air Terminals placing them in a specific location of a Space, so I need a script that creates family Instances with the correct Host in order to not change the Host of all the instances created manually
ok, so it seems possible…but not entirely trivial
Check the script below. You have to make three inputs for the python node - [0] element type/family symbol, [1] list of your ceilings from the linked model, [2] revit link instance element.
This script places a family instance on the center (more less) of the bottom face of the ceiling.
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
def parseLinkedReference(doc, linkedRef):
reps = linkedRef.ConvertToStableRepresentation(doc).split(':')
res = ''
first=True
for i, s in enumerate(reps):
t = s
if "RVTLINK" in s:
if(i<len(reps)-1):
if reps[i+1]=="0":
t = "RVTLINK"
else:
t = "0:RVTLINK"
else:
t = "0:RVTLINK"
if not first:
res = res + ":" + t
else:
res = t
first = False
ref = Reference.ParseFromStableRepresentation(doc,res)
return ref
doc = DocumentManager.Instance.CurrentDBDocument
family_type = UnwrapElement(IN[0])
hosts = UnwrapElement(IN[1])
linked_instance = UnwrapElement(IN[2])
output = []
TransactionManager.Instance.EnsureInTransaction(doc)
for h in hosts:
reference = HostObjectUtils.GetBottomFaces(h)[0]
linked_reference = reference.CreateLinkReference(linked_instance)
parsed_ref = parseLinkedReference(doc,linked_reference)
face = h.GetGeometryObjectFromReference(reference)
bb = face.GetBoundingBox()
centerUV = bb.Min + (bb.Max-bb.Min)/2
p = face.Evaluate(centerUV)
inst = doc.Create.NewFamilyInstance(parsed_ref,p,XYZ(0,0,0),family_type)
output.append(inst)
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = output
4 Likes
It works perfectly!!! Thank you very much!