diff --git a/nodes/2.x/Element.Location+.dyf b/nodes/2.x/Element.Location+.dyf index f2169aa2..83d3fa0c 100644 --- a/nodes/2.x/Element.Location+.dyf +++ b/nodes/2.x/Element.Location+.dyf @@ -254,7 +254,7 @@ }, { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", - "Code": "import clr\r\nimport math\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.GeometryConversion)\r\n\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\nitems = UnwrapElement(IN[0])\r\n\r\ndef GetCurvePoints(curve):\r\n\treturn curve.GetEndPoint(0).ToPoint(), curve.GetEndPoint(1).ToPoint()\r\n\r\ndef GetLocation(item):\r\n\t# returns the following properties:\r\n\t# [0] point\r\n\t# [1] curve\r\n\t# [2] is point?\r\n\t# [3] is curve?\r\n\t# [4] has location?\r\n\t# [5] rotation angle\r\n\t# [6] has rotation?\r\n\t# [7] is curve loop?\r\n\t# [8] curve loop\r\n\t\r\n\t# default values\r\n\tpoint = None\r\n\tcurveendpoints = None\r\n\tcurve = None\r\n\tispoint = False\r\n\tiscurve = False\r\n\thaslocation = False\r\n\trotationangle = None\r\n\thasrotation = False\r\n\tiscurveloop = False\r\n\tcurveloop = None\r\n\t# template for return statements:\r\n\t# return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\r\n\t# points and text notes\r\n\tif hasattr(item, \"Coord\"): \r\n\t\treturn item.Coord.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# base points and reference points\r\n\tif hasattr(item, \"Position\"): \r\n\t\treturn item.Position.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# independent tags\r\n\tif hasattr(item, \"TagHeadPosition\") and hasattr(item, \"IsMaterialTag\"): \r\n\t\treturn item.TagHeadPosition.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# views\r\n\tif hasattr(item, \"ViewType\") and hasattr(item, \"Origin\"): \r\n\t\tori = item.Origin\r\n\t\tif ori: return ori.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# stair runs and landings\r\n\tif hasattr(item, \"GetFootprintBoundary\"):\r\n\t\tfootprint = [x.ToProtoType() for x in item.GetFootprintBoundary()]\r\n\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, footprint\r\n\t# grids, dimensions and boundary segments\r\n\telif hasattr(item, \"Curve\"): \r\n\t\treturn point, GetCurvePoints(item.Curve), item.Curve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# curtain grid lines\r\n\telif hasattr(item, \"FullCurve\"): \r\n\t\treturn point, GetCurvePoints(item.FullCurve), item.FullCurve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# curves\r\n\telif hasattr(item, \"GetEndpoint\"): \r\n\t\treturn point, GetCurvePoints(item), item.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# railings and top rails\r\n\telif hasattr(item, \"GetPath\"):\r\n\t\trailpath = [x.ToProtoType() for x in item.GetPath()]\r\n\t\t# paths with multiple segments\r\n\t\tif len(railpath) > 1: return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, railpath\r\n\t\t# paths with a single segment\r\n\t\telse: return point, GetCurvePoints(railpath[0].ToRevitType()), railpath[0], ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# openings\r\n\telif hasattr(item, \"BoundaryCurves\"):\r\n\t\t# rectangular openings\r\n\t\tif item.IsRectBoundary:\r\n\t\t\tzVals = [x.Z for x in item.BoundaryRect]\r\n\t\t\tp = []\r\n\t\t\tfor o in item.BoundaryRect:\r\n\t\t\t\tfor z in zVals: p.append(XYZ(o.X, o.Y, z).ToPoint())\r\n\t\t\trectloop = Rectangle.ByCornerPoints(p[0], p[1], p[3], p[2]).Explode()\r\n\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, rectloop\r\n\t\t# none-rectangular openings\r\n\t\telse: \r\n\t\t\topeningloop = [x.ToProtoType() for x in item.BoundaryCurves]\r\n\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, openingloop\r\n\t# extrusion roofs\r\n\telif hasattr(item, \"GetProfile\"):\r\n\t\tsketchloop = [x.GeometryCurve.ToProtoType() for x in item.GetProfile()]\r\n\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t# newer sketch-based elements (except walls)\r\n\telif hasattr(item, \"SketchId\") and not hasattr(item, \"WallType\"):\r\n\t\tsketchloop = []\r\n\t\tfor loop in item.Document.GetElement(item.SketchId).Profile:\r\n\t\t\tsketchloop.append([x.ToProtoType() for x in loop])\r\n\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t# other elements\r\n\telif hasattr(item, \"Location\"):\r\n\t\tloc = item.Location\r\n\t\tif loc:\r\n\t\t\t# line-based elements (e.g. walls)\r\n\t\t\tif loc.ToString() == 'Autodesk.Revit.DB.LocationCurve':\r\n\t\t\t\t#loc.Curve.ToProtoType()\r\n\t\t\t\ttry: return point, GetCurvePoints(loc.Curve), loc.Curve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t\t# return super short curves as startpoint instead\r\n\t\t\t\texcept: return GetCurvePoints(loc.Curve)[0], curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t# point-based elements (e.g. most loadable families)\r\n\t\t\telif loc.ToString() == 'Autodesk.Revit.DB.LocationPoint':\r\n\t\t\t\tif hasattr(loc, \"Rotation\"):\r\n\t\t\t\t\trotationangle = math.degrees(loc.Rotation)\r\n\t\t\t\t\thasrotation = True\r\n\t\t\t\treturn loc.Point.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t# some elements have a location property but don't return curves or points\r\n\t\t\telse:\r\n\t\t\t\t# earlier sketch-based elements (e.g. floor slabs)\r\n\t\t\t\ttry:\r\n\t\t\t\t\tsketchloop = []\r\n\t\t\t\t\tfor ref in HostObjectUtils.GetTopFaces(item):\r\n\t\t\t\t\t\tgeomref = item.GetGeometryObjectFromReference(ref)\r\n\t\t\t\t\t\tif geomref: \r\n\t\t\t\t\t\t\tboundaryloops = geomref.GetEdgesAsCurveLoops()\r\n\t\t\t\t\t\t\tfor loop in boundaryloops:\r\n\t\t\t\t\t\t\t\tsketchloop.append([x.ToProtoType() for x in loop])\r\n\t\t\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t\t\t\t# other elements we can't process\r\n\t\t\t\t# return defaults in these cases\r\n\t\t\t\texcept:\r\n\t\t\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t# some elements (e.g.groups, curtain panels etc.) have a location property which only returns a NoneType\r\n\t\t# return defaults in these cases\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# in all other cases return defaults\r\n\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\r\nif isinstance(IN[0], list):\r\n\tlocations = [GetLocation(x) for x in items]\r\n\t# Transpose and remove NoneTypes\r\n\tOUT = []\r\n\tfor prop in map(list, zip(*locations)):\r\n\t\tOUT.append(filter(lambda x: x!=None, prop))\r\nelse: OUT = GetLocation(items)", + "Code": "import clr\r\nimport math\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.GeometryConversion)\r\n\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\nitems = UnwrapElement(IN[0])\r\n\r\ndef GetCurvePoints(curve):\r\n\treturn curve.GetEndPoint(0).ToPoint(), curve.GetEndPoint(1).ToPoint()\r\n\r\ndef GetLocation(item):\r\n\t# returns the following properties:\r\n\t# [0] point\r\n\t# [1] curve\r\n\t# [2] is point?\r\n\t# [3] is curve?\r\n\t# [4] has location?\r\n\t# [5] rotation angle\r\n\t# [6] has rotation?\r\n\t# [7] is curve loop?\r\n\t# [8] curve loop\r\n\t# default values\r\n\tpoint = None\r\n\tcurveendpoints = None\r\n\tcurve = None\r\n\tispoint = False\r\n\tiscurve = False\r\n\thaslocation = False\r\n\trotationangle = None\r\n\thasrotation = False\r\n\tiscurveloop = False\r\n\tcurveloop = None\r\n\t# template for return statements:\r\n\t# return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# points and text notes\r\n\tif hasattr(item, \"Coord\"): \r\n\t\treturn item.Coord.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# base points and reference points\r\n\tif hasattr(item, \"Position\"): \r\n\t\treturn item.Position.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# independent tags\r\n\tif hasattr(item, \"TagHeadPosition\") and hasattr(item, \"IsMaterialTag\"): \r\n\t\treturn item.TagHeadPosition.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# views\r\n\tif hasattr(item, \"ViewType\") and hasattr(item, \"Origin\"): \r\n\t\tori = item.Origin\r\n\t\tif ori: return ori.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# stair runs and landings\r\n\tif hasattr(item, \"GetFootprintBoundary\"):\r\n\t\tfootprint = [x.ToProtoType() for x in item.GetFootprintBoundary()]\r\n\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, footprint\r\n\t# grids, dimensions and boundary segments\r\n\telif hasattr(item, \"Curve\"): \r\n\t\treturn point, GetCurvePoints(item.Curve), item.Curve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# curtain grid lines\r\n\telif hasattr(item, \"FullCurve\"): \r\n\t\treturn point, GetCurvePoints(item.FullCurve), item.FullCurve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# curves\r\n\telif hasattr(item, \"GetEndpoint\"): \r\n\t\treturn point, GetCurvePoints(item), item.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# railings and top rails\r\n\telif hasattr(item, \"GetPath\"):\r\n\t\trailpath = []\r\n\t\tfor x in item.GetPath():\r\n\t\t\ttry: railpath.append(x.ToProtoType())\r\n\t\t\texcept: pass\r\n\t\t# paths with multiple segments\r\n\t\tif len(railpath) > 1: return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, railpath\r\n\t\t# paths with a single segment\r\n\t\telif len(railpath) == 1: return point, GetCurvePoints(railpath[0].ToRevitType()), railpath[0], ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t# paths without legible segments\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# openings\r\n\telif hasattr(item, \"BoundaryCurves\"):\r\n\t\t# rectangular openings\r\n\t\tif item.IsRectBoundary:\r\n\t\t\tzVals = [x.Z for x in item.BoundaryRect]\r\n\t\t\tp = []\r\n\t\t\tfor o in item.BoundaryRect:\r\n\t\t\t\tfor z in zVals: p.append(XYZ(o.X, o.Y, z).ToPoint())\r\n\t\t\trectloop = Rectangle.ByCornerPoints(p[0], p[1], p[3], p[2]).Explode()\r\n\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, rectloop\r\n\t\t# none-rectangular openings\r\n\t\telse: \r\n\t\t\topeningloop = [x.ToProtoType() for x in item.BoundaryCurves]\r\n\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, openingloop\r\n\t# extrusion roofs\r\n\telif hasattr(item, \"GetProfile\"):\r\n\t\tsketchloop = [x.GeometryCurve.ToProtoType() for x in item.GetProfile()]\r\n\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t# newer sketch-based elements (except walls)\r\n\telif hasattr(item, \"SketchId\") and not hasattr(item, \"WallType\"):\r\n\t\tsketch = item.Document.GetElement(item.SketchId)\r\n\t\tif sketch:\r\n\t\t\tsketchloop = []\r\n\t\t\tfor loop in sketch.Profile:\r\n\t\t\t\tsketchloop.append([x.ToProtoType() for x in loop])\r\n\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# other elements\r\n\telif hasattr(item, \"Location\"):\r\n\t\tloc = item.Location\r\n\t\tif loc:\r\n\t\t\t# line-based elements (e.g. walls)\r\n\t\t\tif loc.ToString() == 'Autodesk.Revit.DB.LocationCurve':\r\n\t\t\t\t#loc.Curve.ToProtoType()\r\n\t\t\t\ttry: return point, GetCurvePoints(loc.Curve), loc.Curve.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t\t# return super short curves as startpoint instead\r\n\t\t\t\texcept: return GetCurvePoints(loc.Curve)[0], curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t# point-based elements (e.g. most loadable families)\r\n\t\t\telif loc.ToString() == 'Autodesk.Revit.DB.LocationPoint':\r\n\t\t\t\tif hasattr(loc, \"Rotation\"):\r\n\t\t\t\t\trotationangle = math.degrees(loc.Rotation)\r\n\t\t\t\t\thasrotation = True\r\n\t\t\t\treturn loc.Point.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t\t# some elements have a location property but don't return curves or points\r\n\t\t\telse:\r\n\t\t\t\t# earlier sketch-based elements (e.g. floor slabs)\r\n\t\t\t\ttry:\r\n\t\t\t\t\tsketchloop = []\r\n\t\t\t\t\tfor ref in HostObjectUtils.GetTopFaces(item):\r\n\t\t\t\t\t\tgeomref = item.GetGeometryObjectFromReference(ref)\r\n\t\t\t\t\t\tif geomref: \r\n\t\t\t\t\t\t\tboundaryloops = geomref.GetEdgesAsCurveLoops()\r\n\t\t\t\t\t\t\tfor loop in boundaryloops:\r\n\t\t\t\t\t\t\t\tsketchloop.append([x.ToProtoType() for x in loop])\r\n\t\t\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop\r\n\t\t\t\t# other elements we can't process\r\n\t\t\t\t# return defaults in these cases\r\n\t\t\t\texcept:\r\n\t\t\t\t\treturn point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t\t# some elements (e.g.groups, curtain panels etc.) have a location property which only returns a NoneType\r\n\t\t# return defaults in these cases\r\n\t\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\t# in all other cases return defaults\r\n\telse: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop\r\n\r\nif isinstance(IN[0], list):\r\n\tlocations = [GetLocation(x) for x in items]\r\n\t# Transpose and remove NoneTypes\r\n\tOUT = []\r\n\tfor prop in map(list, zip(*locations)):\r\n\t\tOUT.append(filter(lambda x: x!=None, prop))\r\nelse: OUT = GetLocation(items)", "Engine": "IronPython2", "EngineName": "IronPython2", "VariableInputPorts": true, @@ -372,7 +372,7 @@ { "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore", "ElementResolver": null, - "Symbol": "mulipleCurves", + "Symbol": "multipleCurves", "Id": "b813a1a842eb4e06ae62ecc7b85490cf", "NodeType": "OutputNode", "Inputs": [ @@ -480,15 +480,15 @@ }, "Camera": { "Name": "_Hintergrundvorschau", - "EyeX": -17.0, - "EyeY": 24.0, - "EyeZ": 50.0, - "LookX": 12.0, - "LookY": -13.0, - "LookZ": -58.0, - "UpX": 0.0, - "UpY": 1.0, - "UpZ": 0.0 + "EyeX": 22.8149217995287, + "EyeY": 18.420589478297671, + "EyeZ": 10.847673223231684, + "LookX": -19.530970141825357, + "LookY": -17.02777187159991, + "LookZ": -29.163308457639737, + "UpX": -0.12990062218175127, + "UpY": 0.97236993395254079, + "UpZ": -0.19396537525510416 }, "ConnectorPins": [], "NodeViews": [ @@ -570,7 +570,7 @@ "Excluded": false, "ShowGeometry": true, "X": 257.96244634730249, - "Y": 139.08530042928237 + "Y": 137.79975858374803 }, { "Id": "f049edbfdc904d9d8d55aec33858083d", diff --git a/nodes/2.x/python/Element.Location+.py b/nodes/2.x/python/Element.Location+.py index 2f595c8a..c6083442 100644 --- a/nodes/2.x/python/Element.Location+.py +++ b/nodes/2.x/python/Element.Location+.py @@ -26,7 +26,6 @@ def GetLocation(item): # [6] has rotation? # [7] is curve loop? # [8] curve loop - # default values point = None curveendpoints = None @@ -40,7 +39,6 @@ def GetLocation(item): curveloop = None # template for return statements: # return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop - # points and text notes if hasattr(item, "Coord"): return item.Coord.ToPoint(), curveendpoints, curve, True, iscurve, True, rotationangle, hasrotation, iscurveloop, curveloop @@ -70,11 +68,16 @@ def GetLocation(item): return point, GetCurvePoints(item), item.ToProtoType(), ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop # railings and top rails elif hasattr(item, "GetPath"): - railpath = [x.ToProtoType() for x in item.GetPath()] + railpath = [] + for x in item.GetPath(): + try: railpath.append(x.ToProtoType()) + except: pass # paths with multiple segments if len(railpath) > 1: return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, railpath # paths with a single segment - else: return point, GetCurvePoints(railpath[0].ToRevitType()), railpath[0], ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop + elif len(railpath) == 1: return point, GetCurvePoints(railpath[0].ToRevitType()), railpath[0], ispoint, True, True, rotationangle, hasrotation, iscurveloop, curveloop + # paths without legible segments + else: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop # openings elif hasattr(item, "BoundaryCurves"): # rectangular openings @@ -95,10 +98,13 @@ def GetLocation(item): return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop # newer sketch-based elements (except walls) elif hasattr(item, "SketchId") and not hasattr(item, "WallType"): - sketchloop = [] - for loop in item.Document.GetElement(item.SketchId).Profile: - sketchloop.append([x.ToProtoType() for x in loop]) - return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop + sketch = item.Document.GetElement(item.SketchId) + if sketch: + sketchloop = [] + for loop in sketch.Profile: + sketchloop.append([x.ToProtoType() for x in loop]) + return point, curveendpoints, curve, ispoint, iscurve, True, rotationangle, hasrotation, True, sketchloop + else: return point, curveendpoints, curve, ispoint, iscurve, haslocation, rotationangle, hasrotation, iscurveloop, curveloop # other elements elif hasattr(item, "Location"): loc = item.Location