Skip to content

Commit

Permalink
fixed #384
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Nov 11, 2023
1 parent c3ce7e5 commit dcab13d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nodes/2.x/Element.SuperComponent.dyf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\ndef GetSuperComponent(item):\r\n\t# nested families\r\n\tif hasattr(item, \"SuperComponent\"): return item.SuperComponent\r\n\t# beam systems\r\n\tif hasattr(item, \"BeamBelongsTo\"): return BeamSystem.BeamBelongsTo(item)\r\n\t# handrails\r\n\tif hasattr(item, \"HostRailingId\"): return item.Document.GetElement(item.HostRailingId)\r\n\t# stair components\r\n\telif hasattr(item, \"GetStairs\"): return item.GetStairs()\r\n\t# grid segments\r\n\telif item.GetType().ToString() == 'Autodesk.Revit.DB.Grid': \r\n\t\tsc = MultiSegmentGrid.GetMultiSegementGridId(item)\r\n\t\tif sc: return item.Document.GetElement(sc)\r\n\t\telse: return None\r\n\telse: return None\r\n\r\nitems = UnwrapElement(IN[0])\r\n\r\nif isinstance(IN[0], list): OUT = [GetSuperComponent(x) for x in items]\r\nelse: OUT = GetSuperComponent(items)",
"Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\ndef GetSuperComponent(item):\r\n\t# nested families\r\n\tif hasattr(item, \"SuperComponent\"): return item.SuperComponent\r\n\t# beam systems\r\n\tif hasattr(item, \"BeamBelongsTo\"): return BeamSystem.BeamBelongsTo(item)\r\n\t# handrails\r\n\tif hasattr(item, \"HostRailingId\"): return item.Document.GetElement(item.HostRailingId)\r\n\t# stair components\r\n\telif hasattr(item, \"GetStairs\"): return item.GetStairs()\r\n\t# site subregions\r\n\telif hasattr(item, \"IsSiteSubRegion\"):\r\n\t\tif item.IsSiteSubRegion:\r\n\t\t\treturn item.Document.GetElement(item.AsSiteSubRegion().HostId)\r\n\t# grid segments\r\n\telif item.GetType().ToString() == 'Autodesk.Revit.DB.Grid': \r\n\t\tsc = MultiSegmentGrid.GetMultiSegementGridId(item)\r\n\t\tif sc: return item.Document.GetElement(sc)\r\n\t\telse: return None\r\n\telse: return None\r\n\r\nitems = UnwrapElement(IN[0])\r\n\r\nif isinstance(IN[0], list): OUT = [GetSuperComponent(x) for x in items]\r\nelse: OUT = GetSuperComponent(items)",
"Engine": "IronPython2",
"VariableInputPorts": true,
"Id": "e3c35b2105004cd2bc7b62c5c797f69e",
Expand Down
15 changes: 11 additions & 4 deletions nodes/2.x/python/Element.SuperComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
from Autodesk.Revit.DB import *

def GetSuperComponent(item):
if hasattr(item, "SuperComponent"):
sc = item.SuperComponent
if sc: return sc
else: return BeamSystem.BeamBelongsTo(item)
# nested families
if hasattr(item, "SuperComponent"): return item.SuperComponent
# beam systems
if hasattr(item, "BeamBelongsTo"): return BeamSystem.BeamBelongsTo(item)
# handrails
if hasattr(item, "HostRailingId"): return item.Document.GetElement(item.HostRailingId)
# stair components
elif hasattr(item, "GetStairs"): return item.GetStairs()
# site subregions
elif hasattr(item, "IsSiteSubRegion"):
if item.IsSiteSubRegion:
return item.Document.GetElement(item.AsSiteSubRegion().HostId)
# grid segments
elif item.GetType().ToString() == 'Autodesk.Revit.DB.Grid':
sc = MultiSegmentGrid.GetMultiSegementGridId(item)
if sc: return item.Document.GetElement(sc)
else: return None
else: return None

Expand Down

0 comments on commit dcab13d

Please sign in to comment.