Bounce on link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright (c) mostafa el ayoubi | |
#www.data-shapes.net 2016 elayoubi.mostafa@gmail.com | |
import clr | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import* | |
clr.AddReference('ProtoGeometry') | |
from Autodesk.DesignScript.Geometry import * | |
clr.AddReference('RevitServices') | |
from RevitServices.Persistence import DocumentManager | |
doc = DocumentManager.Instance.CurrentDBDocument | |
#Document UI Units | |
UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits | |
#Inputs : Points, Direction, 3D View | |
if isinstance(IN[0],list): | |
points = [XYZ(UnitUtils.ConvertToInternalUnits(i.X,UIunit),UnitUtils.ConvertToInternalUnits(i.Y,UIunit),UnitUtils.ConvertToInternalUnits(i.Z,UIunit)) for i in IN[0]] | |
else: | |
points = [XYZ(UnitUtils.ConvertToInternalUnits(IN[0].X,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Y,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Z,UIunit))] | |
direction = XYZ(IN[1].X,IN[1].Y,IN[1].Z) | |
view = UnwrapElement(IN[2]) | |
ex = [] | |
pts = [] | |
ri = ReferenceIntersector(view) | |
ri.FindReferencesInRevitLinks = True | |
for p in points: | |
ref = ri.FindNearest(p,direction) | |
if ref == None: | |
pts.append(None) | |
else: | |
refp = ref.GetReference().GlobalPoint | |
pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit))) | |
OUT = pts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment