Hi. I want to place the lamp (family on the face) in certain coordinates.
IN [0] - the surface on which the fixtures will be placed.
IN [1] - coordinates on the surface
IN [2] - Family type.
The surface on which I want to place the element is in the linked file.
When I press start, the program closes.
Could you tell me why this is happening?
Last picture means “Catastrophic error occurred. The application will be closed. Save changes?”
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
host = IN[0]
ftype = UnwrapElement(IN[1])
pts =IN[2]
ref1=[]
tt = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i in xrange(len(pts) ):
ref1 = host[i].Tags.LookupTag("RevitFaceReference")
uv1 = host[i].UVParameterAtPoint(pts[i])
dir1 = host[i].TangentAtUParameter(uv1.U,uv1.V).ToXyz()
try:
inst1 = doc.Create.NewFamilyInstance(ref1,pts[i].ToXyz(),dir1,ftype)
tt.append(inst1.ToDSType(False) )
except: tt.append(None)
TransactionManager.Instance.TransactionTaskDone()
OUT=tt