Skip to content

Commit

Permalink
#403 safeguard for when a link isn't loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Mar 14, 2024
1 parent e455cfe commit c160b15
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nodes/2.x/Dimension.ReferencedElements.dyf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.Elements)\r\n\r\ndef GetDimensionReferences(item):\r\n\tif hasattr(item, \"References\"):\r\n\t\trefs = []\r\n\t\tlinkInstances = []\r\n\t\tfor r in item.References:\r\n\t\t\tif r.LinkedElementId != ElementId.InvalidElementId: \r\n\t\t\t\trefs.append(item.Document.GetElement(r.ElementId).GetLinkDocument().GetElement(r.LinkedElementId))\r\n\t\t\t\tlinkInstances.append(item.Document.GetElement(r.ElementId))\r\n\t\t\telse: \r\n\t\t\t\trefs.append(item.Document.GetElement(r.ElementId))\r\n\t\t\t\tlinkInstances.append(None)\r\n\t\treturn refs, linkInstances\t\t\r\n\telse: return None\r\n\r\ndimensions = UnwrapElement(IN[0])\r\n\r\nif isinstance(IN[0], list): \r\n\tif len(IN[0]) > 0: OUT = list(zip(*[GetDimensionReferences(x) for x in dimensions]))\r\n\telse: OUT = [[],[]]\r\nelse: OUT = GetDimensionReferences(dimensions)",
"Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.Elements)\r\n\r\ndef GetDimensionReferences(item):\r\n\tif hasattr(item, \"References\"):\r\n\t\trefs = []\r\n\t\tlinkInstances = []\r\n\t\tfor r in item.References:\r\n\t\t\tif r.LinkedElementId != ElementId.InvalidElementId: \r\n\t\t\t\tif item.Document.GetElement(r.ElementId).GetLinkDocument():\r\n\t\t\t\t\trefs.append(item.Document.GetElement(r.ElementId).GetLinkDocument().GetElement(r.LinkedElementId))\r\n\t\t\t\t# if the link isn't loaded, just return the RevitLinkInstance instead of the actual element\r\n\t\t\t\telse: refs.append(item.Document.GetElement(r.ElementId))\r\n\t\t\t\tlinkInstances.append(item.Document.GetElement(r.ElementId))\r\n\t\t\telse: \r\n\t\t\t\trefs.append(item.Document.GetElement(r.ElementId))\r\n\t\t\t\tlinkInstances.append(None)\r\n\t\treturn refs, linkInstances\t\t\r\n\telse: return None\r\n\r\ndimensions = UnwrapElement(IN[0])\r\n\r\nif isinstance(IN[0], list): \r\n\tif len(IN[0]) > 0: OUT = list(zip(*[GetDimensionReferences(x) for x in dimensions]))\r\n\telse: OUT = [[],[]]\r\nelse: OUT = GetDimensionReferences(dimensions)",
"Engine": "IronPython2",
"VariableInputPorts": true,
"Id": "79097b4a5ab74d4c9b96e29dabdad192",
Expand Down Expand Up @@ -286,8 +286,8 @@
}
],
"Annotations": [],
"X": 0.0,
"Y": 0.0,
"X": 1408.0,
"Y": 186.0,
"Zoom": 1.0
}
}

0 comments on commit c160b15

Please sign in to comment.