I have some lines, and some generic annotations coming from a linked model.
I’ve collected the elements via BIMorph Nodes, but when I get the location the coordinate of the generic annotation is not even close.
The PBP/IO X & Y values are identical.
I’m trying to find the generic annotation that sits within the surface of a closed loop of lines to be able to identify the zone because there is no filled region or room, so once I have the correct position of the generic annotation, I’ll find which loop/surface the point sits in, then I can match the surface/loop to the zone.
All the different nodes I’ve tried report the same coordinate for the generic annotation:
The code must be adapted to your type of annotation
import clr
import sys
import System
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)
out = []
#Preparing input from dynamo to revit
lnk_instance : DB.RevitLinkInstance = UnwrapElement(IN[0])
tf = lnk_instance.GetTotalTransform()
lnk_doc = lnk_instance.GetLinkDocument()
lst_tags = FilteredElementCollector(lnk_doc).OfCategory(BuiltInCategory.OST_ParkingTags).WhereElementIsNotElementType().ToList()
for t in lst_tags:
t : DB.IndependentTag
lnk_view = lnk_doc.GetElement(t.OwnerViewId)
if hasattr(lnk_view, "GenLevel"):
z = lnk_view.GenLevel.ProjectElevation
pt = XYZ(t.TagHeadPosition.X, t.TagHeadPosition.Y, z)
pt = tf.OfPoint(pt)
out.append(pt.ToPoint())
OUT = out
You need to use LinkElement.Location node. Using Element.GetLocation node works with Bimorph LinkElement’s but it will only return the location relative to Revit’s file centre, ignoring any transform your PBP applies, which is why its so far away. Whenever you use LinkElement’s always use nodes from its library first and Dynamo Element nodes (or third-party package nodes) second to get consistent results.