Create Instances of linked Revit model on specified locations

The problem is simply you are rotating the linked element using the revitLinkTypeId
You need to use the placed instance id

Simply change the following :
From
ElementTransformUtils.RotateElement(doc,uLink.Id,axis,math.pi)

To
ElementTransformUtils.RotateElement(doc,newInstance.Id,axis,math.pi)

Also you need to use the X and Y and Z from the converted XYZ, not from the location input
So change the following too :
From
axis = Line.CreateBound(xyz, XYZ(location.X,location.Y,location.Z +1))

To
axis = Line.CreateBound(xyz, XYZ(xyz.X,xyz.Y,xyz.Z +1))

As for multiple inputs of locations and rotations :

doc = DocumentManager.Instance.CurrentDBDocument
link = IN[0]
location = IN[1]
rotations = IN[2]
uLink = UnwrapElement(link)
id=uLink.Id
xyz = []
result = []

for e in location:
	xyz.append(e.ToXyz())
	
TransactionManager.Instance.EnsureInTransaction(doc)


for eachpoint in xyz:
	newInstance = RevitLinkInstance.Create(doc,id,ImportPlacement.Origin)
	loc = newInstance.Location
	new2 = loc.Move(eachpoint)
	result.append(newInstance)
	instanceid = newInstance.Id
	axis = Line.CreateBound(eachpoint, XYZ(eachpoint.X,eachpoint.Y,eachpoint.Z +1))
	ElementTransformUtils.RotateElement(doc,instanceid,axis,rotations[xyz.index(eachpoint)]*math.pi/180)

TransactionManager.Instance.TransactionTaskDone()

OUT = result

Hope that help

1 Like