Advertisement
goofer

Dynamo python syntax

Dec 15th, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. import clr
  2. clr.AddReference('RevitAPI')
  3. from Autodesk.Revit.DB import *
  4.  
  5. clr.AddReference("RevitNodes")
  6. import Revit
  7. clr.ImportExtensions(Revit.GeometryConversion)
  8.  
  9. items = UnwrapElement(IN[0])
  10. pointlist = list()
  11. rotation = list()
  12. curvepointlist = list()
  13. ispoint = list()
  14. iscurve = list()
  15. curves = list()
  16. haslocation = list()
  17.  
  18. for item in items:
  19.     try:
  20.         # points and text notes
  21.         pointlist.append(item.Coord.ToPoint())
  22.         ispoint.append(True)
  23.         iscurve.append(False)
  24.         haslocation.append(True)
  25.     except:
  26.         try:
  27.             loc = item.Location
  28.             if loc.ToString() == 'Autodesk.Revit.DB.LocationCurve':
  29.                 # line-based elements (e.g. walls)
  30.                 curvepoints = (loc.Curve.GetEndPoint(0).ToPoint(),loc.Curve.GetEndPoint(1).ToPoint())
  31.                 curvepointlist.append(curvepoints)
  32.                 curves.append(loc.Curve.ToProtoType())
  33.                 ispoint.append(False)
  34.                 iscurve.append(True)
  35.                 haslocation.append(True)
  36.             elif loc.ToString() == 'Autodesk.Revit.DB.LocationPoint':
  37.                 # point-based elements
  38.                 pointlist.append(loc.Point.ToPoint())
  39.                 rotation.append(loc.Rotation)
  40.                 ispoint.append(True)
  41.                 iscurve.append(False)
  42.                 haslocation.append(True)
  43.             else:
  44.                 ispoint.append(False)
  45.                 iscurve.append(False)
  46.                 haslocation.append(False)
  47.         except:
  48.             try:
  49.                 # curves
  50.                 curvepoints = (item.GetEndPoint(0).ToPoint(),item.GetEndPoint(1).ToPoint())
  51.                 curvepointlist.append(curvepoints)
  52.                 curves.append(item.ToProtoType())
  53.                 ispoint.append(False)
  54.                 iscurve.append(True)
  55.                 haslocation.append(True)
  56.             except:
  57.                 ispoint.append(False)
  58.                 iscurve.append(False)
  59.                 haslocation.append(False)
  60. OUT = (pointlist,rotation,curvepointlist,curves,ispoint,iscurve,haslocation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement