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.
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.
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:
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
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
linkInst = UnwrapElement(IN[0])
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).
DesignScript: linkOffsetVector = Vector.ByTwoPoints(Point.ByCoordinates(0, 0, 0), linkOffsetPoint);
Or with nodes:
Then you can translate your point along this vector using Designscript:
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:
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
original copyrights:
Copyright(c) 2017, Dimitar Venkov
@5devene, dimitar.ven@gmail.com
www.badmonkeys.net
"""
import clr
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import RevitLinkInstance
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
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)
else:
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.
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.