So I have a file with geometry, linked by Shared Coordinates, while my rooms are in the host model:
However, after selecting all the rooms’ geometry and doors, windows, walls, etc from the geometry file, they appear to be on completely different places:
Any ideas why? I am trying to calculate the areas of room finishes in the case with linked geometry and rooms in a host model. Everything seemed to work fine, until I tried with a project, where links are placed by shared coordinates.
The position of the elements is calculated from the origin.
Revit’s origin and Dynamo’s origin match, you only need to translate it in coordinates from your Shared Coordinate.
The are some nodes in the GeniusLoci package to get it back in position.
Thx, I will give it a try
I recently solved this problem by writing a short python script that gets the linked model’s totaltransform then converting that to a vector and translating the linked element’s location along this vector.
That’s cool, could you please share the script?
I tried different options and I still can’t get it to work, here is the geometry from the host model (blue) and the one from the geometry model (red). You can see the different transforms and none of them intersect:
From what I see, I can only get it to translate the geometry in Z direction, it does not detect X and Y difference in coordinates.
Sorry for the delay, here’s the python code which takes a document (linked instance) as input and outputs the linked document’s total transform as a point.
#Written by Scott Lebow
from Autodesk.Revit.DB import *
linkInst = UnwrapElement(IN)
totalTransform = linkInst.GetTotalTransform()
origin = XYZ(0, 0, 0)
offsetPoint = totalTransform.OfPoint(origin)
#Assign your output to the OUT variable.
OUT = offsetPoint.ToPoint()
From here you can create a Vector using this point (linkOffsetPoint).
linkOffsetVector = Vector.ByTwoPoints(Point.ByCoordinates(0, 0, 0), linkOffsetPoint);
Or with nodes:
Then you can translate your point along this vector using Designscript:
newLocations = Point.Add(linkedElements.Location, linkOffsetVector);
Or the Point.Add node:
Thx, Scott! That brought me as close as I could get so far:
However, there is still a weird rotation angle, while the BasePoint reports that angle to true north is set to 0…:
I am now trying to find out where that comes from
Try BimorphNodes LinkElements they already include built-in logic to handle the transformation of linked elements and their geometry in the host document.
I tried that initially. I finally got what I needed from GeniusLoci’s Get Project Locations node. For some reason, nothing else could read the True North correctly:
The node also reads the coordinates as it should - returns identical values with the one from Scott’s script. So I will just use that one.
I’m glad it finally works, but I will need to dig deeper and find out why so many nodes failed for this file. Could it be related to the new internal origin in 2021 somehow? Thx to everyone for the support
Its a problem with the Python script as it converts the transform to a translation and you need the former not the latter to position the geometry correctly. You could convert the transform to a Dynamo CS in Python using
ToCoordinateSystem() or achieve your workflow with significant performance improvements using two BimorphNodes:
I wanted to thank Danail momchilov, ScottL and Tomas mahon for their contributions, I was dealing with this issue all afternoon and I finally managed to get the revitlinkinstances geometry location in my host model. If I get consent from my work staff I can publish my script which transforms all walls from links into Dynamo solids with original rotation and xy translation . Thankyou so much.
Diving further after this topic and as an alternative to the solution Thomas provided, I found a node from the amazing archi - lab package, that lets you select elements from linked models directly and returns the total transform as well:
you could then get their geometry and use the transform to get them on their right location:
Just thought it might come usefull to you, for me this workflow works quite well.
Based on SelectLinkedElements node, I created a simplification of the code, that lets you select only a link instance and returns its transform, might be usefull to you also:
based on a simplification of the
SelectLinkedElements node in archi-lab package
Copyright(c) 2017, Dimitar Venkov
from Autodesk.Revit.UI import *
from Autodesk.Revit.DB import RevitLinkInstance
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Element
ot2 = Selection.ObjectType.LinkedElement
li_ref = sel1.PickObject(ot1, "Please, select a link instance.")
link1 = doc.GetElement(li_ref.ElementId)
if isinstance(link1, RevitLinkInstance):
OUT = link1, link1.GetTotalTransform().ToCoordinateSystem(True)
OUT = 'Link instance not selected...100 tei prai6'
Thanks for your contribution, I have tried using the transform.TocoordinateSystem() method.Its working very slowly so Im using the bimorph nodes and it seems to be faster.Are you using the archilab package and then transforming elements to designscript geometries? and/or the bimorph nodes? Do you which procedure is faster?
I depends on what you are trying to achieve. I have been using both for different purposes. The archi-lab node lets you select only certain elements from the link instance. Then in combination with geometry.transform node it works quite well for me (and fast). In case I need a whole category of elements from the link, I would definitely use Bimorph.
I didn’t get the designscript part, what do you mean? What are you trying to achieve? Getting elements’ geometry or solids is actually a quite slow process.
When you use the Geometry.Transform method you are converting elements to Autodesk.DesignsScript.Geometry.Solids , I find that this solid conversion method is slow(I have almost 6 linkInstances containing 1800 walls and its taking 1.5 minutes for this process to finish) .Im trying to extract walls from revit link instances and ive done so with the Transform.ToCoordinateSystem() + Geometry.Transform method and the bimorph nodes method using LinkElement.ByCategory. I wanted to compare these methods and ask you about the archilab package method, which I will try to also use and compare speed times with the other 2 methods that I mentioned .
I see. One of the tasks I am using this workflow for, is structural openings in floors. In this case, I would get all elements’ bounding boxes (since I need rectangular openings anyway) and then use boundingbox.tocuboid node to get the solids of their bounding boxes. Only then I transform the geometry and it works well and fast. I just dont know if this would work fine in your case. If you would test it someday, please let me know what’s the result
The Geometry.Transform worked perfectly for me! it makes all the linked model use the project origin to operate other nodes, I was trying to get intersections, the MEP model and walls were miles away from each other in Dynamo.
Thanks again for your time
thank you ! glad you found it useful
edit: it’s actually Dimitar Venkov we should all thank
Hi I use BIMorpthNodes but the room perimeters from linked model return in host model as shifted. Can you please help ?
Hi, try using the code that I posted, it lest you select the link and gets its transform, then you can move the link’s rooms geometry on the correct location, based on that transform. Check my last post.