Moving a linked RVT file along the vector X and Y with Dynamo

Hi Everybody! I would like to move linked RVT file by set values along the vector X and Y. I installed an additional library but still I couldn’t find right node. At the moment I was able to move selected objects and whole levels but only those that were created directly in a the project. I want to get into the linked files. Any ideas? Thanks for help in advance!

Do you want to move a Link Instance or to move particular items in the linked model?

Hi @Tomasz I want to move for example 30 RVT links in the same time by set values on the X and Y axes.

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

l = UnwrapElement(IN[0])
v = UnwrapElement(IN[1]).ToXyz()

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
OUT = l.Location.Move(v)
TransactionManager.Instance.TransactionTaskDone()

2 Likes

Great! Thanks @Tomasz for nice script :ok_hand:t2: Will be possible to make a move for all the linked files? This script is working perfectly with one selected element. Will be possible to make an action choosing RVT Links category?

The second image shows how to select all link instances. If you need help with sorting logic - post your graph.

Try this:

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

links = UnwrapElement(IN[0])
vector = UnwrapElement(IN[1]).ToXyz()

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
for l in links:
    l.Location.Move(vector )
TransactionManager.Instance.TransactionTaskDone()
1 Like

Unfortunately when I selected two Revit Links or I use a second method with Element Types at the end I have seen warning. Please have a look.

Please see post above.

PS. Pozdrowienia z Wrocławia!

1 Like

Awesome! Thanks a lot!
P.S. Będąc we Wrocławiu stawiam piwo! Chyba, że u mnie w Krakowie? :beers:

3 Likes

Hi, Tomasz. I used your script to move a revit link and the result is that the linked file had been move with a wrong distance. For example, a vector X=1000,Y=0,Z=0 in dynamo while the vector in revit is X=320040 ,Y=0,Z=0. Do you know what was wrong?
what is more ,Will be possible to rotation the linked file at the same time ?
thank you very much.


Yes, it is possible to rotate the link using Location.Rotate method.

You also need to convert units. Revit API uses feet and Dynamo is unit less. Here is an example of one approach to convert between units.

Hi @Tomasz,

I’ve moved without problem the model using the previous code.

Now I’m tring to rotate the link on plan xy using internal point as pivot point, but my understanding of python it to understand where is the problem with the code.

If you can please help me :slight_smile:

"
import clr

clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

l = UnwrapElement(IN[0])
v = UnwrapElement(IN[1]).ToXyz()
a = UnwrapElement(IN[2])

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
OUT = l.Rotate(v,a)
TransactionManager.Instance.TransactionTaskDone()
";

try
l.Location.Rotate(v, a)

Could this could be modified so the linked file moves more than one time ? I mean it moves like some steps and we watch it moves step by step

Please create a new topic if original question was answered.