Skip to content

Commit

Permalink
fixed #414
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Jun 2, 2024
1 parent 8a9a344 commit 7c7dfc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nodes/2.x/Element.Name+.dyf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\ndef GetName(item):\r\n\tunwrapped = UnwrapElement(item)\r\n\tif not unwrapped: return None\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.Area\", \"Autodesk.Revit.DB.Architecture.TopographySurface\"):\r\n\t\ttry: return unwrapped.get_Parameter(BuiltInParameter.ROOM_NAME).AsString()\r\n\t\texcept: return unwrapped.Name\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.BuiltInParameter\", \"Autodesk.Revit.DB.BuiltInParameterGroup\", \"Autodesk.Revit.DB.DisplayUnitType\", \"Autodesk.Revit.DB.ParameterType\", \"Autodesk.Revit.DB.UnitSymbolType\", \"Autodesk.Revit.DB.UnitType\"): \r\n\t\ttry: return LabelUtils.GetLabelFor(unwrapped)\r\n\t\texcept: return unwrapped.ToString()\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.Parameter\", \"Autodesk.Revit.DB.FamilyParameter\"): return unwrapped.Definition.Name\r\n\telif unwrapped.GetType().ToString() == (\"Autodesk.Revit.DB.ForgeTypeId\"): \r\n\t\ttry: return LabelUtils.GetLabelForSpec(unwrapped)\r\n\t\texcept: \r\n\t\t\ttry: return LabelUtils.GetLabelForSymbol(unwrapped)\r\n\t\t\texcept: \r\n\t\t\t\ttry: return LabelUtils.GetLabelForUnit(unwrapped)\r\n\t\t\t\texcept: \r\n\t\t\t\t\ttry: return LabelUtils.GetLabelForGroup(unwrapped)\r\n\t\t\t\t\texcept: \r\n\t\t\t\t\t\ttry: return LabelUtils.GetLabelForBuiltinParameter(unwrapped)\r\n\t\t\t\t\t\texcept: \r\n\t\t\t\t\t\t\ttry: return LabelUtils.GetLabelForDiscipline(unwrapped)\r\n\t\t\t\t\t\t\texcept: return unwrapped.TypeId\t\t\t\r\n\telif hasattr(unwrapped, \"GetName\"): return unwrapped.GetName()\r\n\telif hasattr(unwrapped, \"Name\"): return unwrapped.Name\r\n\telif hasattr(item, \"Name\"): return item.Name\r\n\telse: return None\r\n\r\nitems = IN[0]\r\nif isinstance(IN[0], list): OUT = [GetName(x) for x in IN[0]]\r\nelse: OUT = GetName(IN[0])",
"Code": "import clr\r\nimport os\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\ndef GetName(item):\r\n\tunwrapped = UnwrapElement(item)\r\n\tif not unwrapped: return None\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.Area\", \"Autodesk.Revit.DB.Architecture.TopographySurface\"):\r\n\t\ttry: return unwrapped.get_Parameter(BuiltInParameter.ROOM_NAME).AsString()\r\n\t\texcept: return unwrapped.Name\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.BuiltInParameter\", \"Autodesk.Revit.DB.BuiltInParameterGroup\", \"Autodesk.Revit.DB.DisplayUnitType\", \"Autodesk.Revit.DB.ParameterType\", \"Autodesk.Revit.DB.UnitSymbolType\", \"Autodesk.Revit.DB.UnitType\"): \r\n\t\ttry: return LabelUtils.GetLabelFor(unwrapped)\r\n\t\texcept: return unwrapped.ToString()\r\n\telif unwrapped.GetType().ToString() in (\"Autodesk.Revit.DB.Parameter\", \"Autodesk.Revit.DB.FamilyParameter\"): return unwrapped.Definition.Name\r\n\telif unwrapped.GetType().ToString() == \"Revit.Application.Document\": \r\n\t\tif unwrapped.FilePath: return os.path.basename(unwrapped.FilePath)\r\n\t\telse: return None\r\n\telif unwrapped.GetType().ToString() == (\"Autodesk.Revit.DB.ForgeTypeId\"): \r\n\t\ttry: return LabelUtils.GetLabelForSpec(unwrapped)\r\n\t\texcept: \r\n\t\t\ttry: return LabelUtils.GetLabelForSymbol(unwrapped)\r\n\t\t\texcept: \r\n\t\t\t\ttry: return LabelUtils.GetLabelForUnit(unwrapped)\r\n\t\t\t\texcept: \r\n\t\t\t\t\ttry: return LabelUtils.GetLabelForGroup(unwrapped)\r\n\t\t\t\t\texcept: \r\n\t\t\t\t\t\ttry: return LabelUtils.GetLabelForBuiltinParameter(unwrapped)\r\n\t\t\t\t\t\texcept: \r\n\t\t\t\t\t\t\ttry: return LabelUtils.GetLabelForDiscipline(unwrapped)\r\n\t\t\t\t\t\t\texcept: return unwrapped.TypeId\t\t\t\r\n\telif hasattr(unwrapped, \"GetName\"): return unwrapped.GetName()\r\n\telif hasattr(unwrapped, \"Name\"): return unwrapped.Name\r\n\telif hasattr(item, \"Name\"): return item.Name\r\n\telse: return None\r\n\r\nitems = IN[0]\r\nif isinstance(IN[0], list): OUT = [GetName(x) for x in IN[0]]\r\nelse: OUT = GetName(IN[0])",
"Engine": "IronPython2",
"VariableInputPorts": true,
"Id": "fe1345c4af284ad48eee6a5bbea61e11",
"Inputs": [
Expand All @@ -86,7 +87,7 @@
}
],
"Replication": "Disabled",
"Description": "Führt ein eingebettetes IronPython-Skript aus."
"Description": "Führt ein eingebettetes Python-Skript aus."
}
],
"Connectors": [
Expand All @@ -103,13 +104,14 @@
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"Author": "None provided",
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": false,
"IsVisibleInDynamoLibrary": true,
"Version": "2.6.2.15705",
"Version": "2.12.1.8246",
"RunType": "Manual",
"RunPeriod": "1000"
},
Expand Down
4 changes: 4 additions & 0 deletions nodes/2.x/python/Element.Name+.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clr
import os
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

Expand All @@ -12,6 +13,9 @@ def GetName(item):
try: return LabelUtils.GetLabelFor(unwrapped)
except: return unwrapped.ToString()
elif unwrapped.GetType().ToString() in ("Autodesk.Revit.DB.Parameter", "Autodesk.Revit.DB.FamilyParameter"): return unwrapped.Definition.Name
elif unwrapped.GetType().ToString() == "Revit.Application.Document":
if unwrapped.FilePath: return os.path.basename(unwrapped.FilePath)
else: return None
elif unwrapped.GetType().ToString() == ("Autodesk.Revit.DB.ForgeTypeId"):
try: return LabelUtils.GetLabelForSpec(unwrapped)
except:
Expand Down

0 comments on commit 7c7dfc6

Please sign in to comment.