Create Instances of linked Revit model on specified locations


#1

Hello!
I want to create instances of a linked model on several points. I have my points and the linked model, but i need help creating new instances of the model on each point. Is there a node or a function that does what i want?
Any help is appreciated!


#2

Hi @magnus
MEPover has a node called Copy element to location. Try using that.


#3

thanks for quick reply.
that node does not do anything. it just returns zero

im thinking that it would be something similar to .create.PlaceGroup, but for linked model.
Or maybe something similar to the nodes for creating and placing a familyinstance.
However i can’t find anything.


#4

I think I have found the correct function in Revit API Docs, but i’m not sure how to implement it.
This is the function in C#:

public static RevitLinkInstance Create(
	Document document,
	ElementId revitLinkTypeId
)

With an example:

public void CreateLinkInstances(Document doc, ElementId linkTypeId)
{
// Create revit link instance at origin
RevitLinkInstance.Create(doc, linkTypeId);
RevitLinkInstance instance2 = RevitLinkInstance.Create(doc, linkTypeId);
Location location = instance2.Location;
// Create a second instance of the link and offset it by 100 feet.
location.Move(new XYZ(0, -100, 0));
}

This is how i’ve started:

doc = DocumentManager.Instance.CurrentDBDocument
link = IN[0][0]
inst = IN[0][1]
location = IN[1]
instance = UnwrapElement(inst)
uLink = UnwrapElement(link)
path = instance.GetLinkDocument().PathName
uLink.Create(doc,path,location)

I don’t know if i am at the right track, i suspect that the third input is not a location, but currently i have an error with the second input that says “TypeError: expected ModelPath, got str”

I am eternally grateful if someone could:

  1. explain that TypeError
  2. Tell me if i am on the right track

Edit:
So i figured out how to create a new instance at origin, now i need to place it where i want to

link = IN[0][0]
inst = IN[0][1]
location = IN[1]
instance = UnwrapElement(inst)
uLink = UnwrapElement(link)
id=uLink.Id

TransactionManager.Instance.EnsureInTransaction(doc)

RevitLinkInstance.Create(doc,id,ImportPlacement.Origin)

TransactionManager.Instance.TransactionTaskDone()

#5

I am getting close, it’s not entirely stable, but it works ok
The last thing that i am missing, is the ability to rotate the linked instances.
I was hoping ElementTransformUtils.RotateElement would do the trick, but it does not do anything.
Is there an easy way to rotate the linked instances?
Thanks a lot!

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

TransactionManager.Instance.EnsureInTransaction(doc)

newInstance = RevitLinkInstance.Create(doc,id,ImportPlacement.Origin)
loc = newInstance.Location
new2 = loc.Move(xyz)

#Rotate instance:
axis = Line.CreateBound(xyz, XYZ(location.X,location.Y,location.Z +1))
ElementTransformUtils.RotateElement(doc,uLink.Id,axis,math.pi)

TransactionManager.Instance.TransactionTaskDone()