Rotate a linked RVT file around Z of project internal point with Dynamo

Hi everyone,

I trying to rotate a linked model using some code of python but I’m really newbie and I don’t understand the problem with the code.

starting from an other tread Moving a linked RVT file along the vector X and Y with Dynamo I modified the code to rotate instead of translate the linked model.

I try two different solution but with both I have some problems, can someone please help me.

Solution1:

"
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

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

l = UnwrapElement(IN[0])
p1= UnwrapElement(IN[1]).ToXyz()
p2= UnwrapElement(IN[2]).ToXyz()
a = UnwrapElement(IN[3])
Ln= Line.CreateBound(p1, p2)

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

Solution2:

"
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

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

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

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

Looks like you might have the LinkType and not the LinkInstance. How are you getting your link object?

I select directly the instance with “Select model Element” node.
the same selection work if I use it to translate the link instead of rotate it.

The second error looks like you need to convert your Dynamo line to a Revit line. Unwrapping the curve won’t do that. You’ll have to convert it.
revitGeometryObject = dynamoGeometry.ToRevitType()

THANK YOU @Nick_Boyts !!!
this is great and work really well.

If someone needs, this is the code

"
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

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

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

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

1 Like

Thanks for sharing…
I’m quite new also to dynamo. Can you please share the whole graph so i can try to redo the code?

Sure, for the rotation only, this is the graph

1 Like

Thanks @Danifly :slightly_smiling_face:

Can you help me? does not work

Ciao Cocchiero,

your definition looks correct, can you please read highlight the warning.

did you check if the link is pinned in revit or it’s was linked with shared coordinates and it’s still locked to internal point?

Hi @Danifly I am getting this error.

Can you please help me out for this ?