Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create familyInstanceGetLocation.py #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions revitAPI/familyInstanceGetLocation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

'''
GET ALL POSSIBLE FAILURE MESSAGES
'''
__author__ = 'john pierson - [email protected]'
__twitter__ = '@60secondrevit'
__github__ = '@sixtysecondrevit'
__version__ ='1.0.0'

# dynamo version - 2.6.0
# originally made to answer https://forum.dynamobim.com/t/room-location-point-of-a-family-the-green-dot/58480/2

# import common language runtime
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
# import all classes from Revit DB
from Autodesk.Revit.DB import *

# import Revit dynamo libraries
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# custom definition for location that works with single items or lists
def GetLocation(item):
# if it has a calculation point return that
if item.HasSpatialElementCalculationPoint : return item.GetSpatialElementCalculationPoint().ToPoint()
# if not return the regular location
elif item.Location.GetType().ToString().Contains("LocationPoint") : return item.Location.Point.ToPoint()

else: return None

# the family instances
items = UnwrapElement(IN[0])

# return the results
if isinstance(IN[0], list): OUT = [GetLocation(x) for x in items]
else: OUT = GetLocation(items)