Skip to content

Commit

Permalink
fixed #372
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Apr 1, 2024
1 parent c960734 commit 50463d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
45 changes: 24 additions & 21 deletions nodes/2.x/All Elements of Family Type+.dyf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
],
"Replication": "Disabled",
"Description": "A function parameter, use with custom nodes.\r\n\r\nYou can specify the type and default value for parameter. E.g.,\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
"Description": "Ein Funktionsparameter zur Verwendung mit benutzerdefinierten Blöcken.\r\n\r\nSie können den Typ und den Vorgabewert für den Parameter angeben, z. B.\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore",
Expand All @@ -60,7 +60,7 @@
],
"Outputs": [],
"Replication": "Disabled",
"Description": "A function output, use with custom nodes"
"Description": "Eine Funktionsausgabe zur Verwendung mit benutzerdefinierten Blöcken"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore",
Expand All @@ -86,7 +86,7 @@
}
],
"Replication": "Disabled",
"Description": "A function parameter, use with custom nodes.\r\n\r\nYou can specify the type and default value for parameter. E.g.,\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
"Description": "Ein Funktionsparameter zur Verwendung mit benutzerdefinierten Blöcken.\r\n\r\nSie können den Typ und den Vorgabewert für den Parameter angeben, z. B.\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore",
Expand All @@ -112,12 +112,13 @@
}
],
"Replication": "Disabled",
"Description": "A function parameter, use with custom nodes.\r\n\r\nYou can specify the type and default value for parameter. E.g.,\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
"Description": "Ein Funktionsparameter zur Verwendung mit benutzerdefinierten Blöcken.\r\n\r\nSie können den Typ und den Vorgabewert für den Parameter angeben, z. B.\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
},
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "import System\r\nimport clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager\r\n\r\ndef InstancesOfFamilyType(ft, doc):\r\n\tcollector = FilteredElementCollector(doc)\r\n\tbic = System.Enum.ToObject(BuiltInCategory, ft.Category.Id.IntegerValue)\r\n\tcollector.OfCategory(bic)\r\n\treturn [x for x in collector.ToElements() if x.GetTypeId().IntegerValue == ft.Id.IntegerValue]\r\n\r\nfamtypes = UnwrapElement(IN[0])\r\ninputdoc = UnwrapElement(IN[2])\r\nif not inputdoc: doc = DocumentManager.Instance.CurrentDBDocument\r\nelif inputdoc.GetType().ToString() == \"Autodesk.Revit.DB.RevitLinkInstance\": doc = inputdoc.GetLinkDocument()\r\nelif inputdoc.GetType().ToString() == \"Autodesk.Revit.DB.Document\": doc = inputdoc\r\nelse: doc = DocumentManager.Instance.CurrentDBDocument\r\n\r\nif isinstance(IN[0], list): OUT = [InstancesOfFamilyType(x, doc) for x in famtypes]\r\nelse: OUT = InstancesOfFamilyType(famtypes, doc)",
"Code": "import System\r\nimport clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager\r\n\r\ndef InstancesOfFamilyType(ft, doc):\r\n\tcollector = FilteredElementCollector(doc)\r\n\ttry:\r\n\t\tbic = System.Enum.ToObject(BuiltInCategory, ft.Category.Id.IntegerValue)\r\n\t\tcollector.OfCategory(bic)\r\n\t\treturn [x for x in collector.ToElements() if x.GetTypeId().IntegerValue == ft.Id.IntegerValue]\r\n\texcept: return []\r\n\r\nfamtypes = UnwrapElement(IN[0])\r\ninputdoc = UnwrapElement(IN[2])\r\nif not inputdoc: doc = DocumentManager.Instance.CurrentDBDocument\r\nelif inputdoc.GetType().ToString() == \"Autodesk.Revit.DB.RevitLinkInstance\": doc = inputdoc.GetLinkDocument()\r\nelif inputdoc.GetType().ToString() == \"Autodesk.Revit.DB.Document\": doc = inputdoc\r\nelse: doc = DocumentManager.Instance.CurrentDBDocument\r\n\r\nif isinstance(IN[0], list): OUT = [InstancesOfFamilyType(x, doc) for x in famtypes]\r\nelse: OUT = InstancesOfFamilyType(famtypes, doc)",
"Engine": "IronPython2",
"VariableInputPorts": true,
"Id": "cd510746fdcd4cc3a2e1f69a6c8efa03",
"Inputs": [
Expand Down Expand Up @@ -161,7 +162,7 @@
}
],
"Replication": "Disabled",
"Description": "Runs an embedded IronPython script."
"Description": "Führt ein eingebettetes Python-Skript aus."
}
],
"Connectors": [
Expand All @@ -187,18 +188,20 @@
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"Author": "None provided",
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": false,
"IsVisibleInDynamoLibrary": true,
"Version": "2.0.1.5055",
"Version": "2.12.1.8246",
"RunType": "Manual",
"RunPeriod": "1000"
},
"Camera": {
"Name": "Background Preview",
"Name": "Hintergrundvorschau",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
Expand All @@ -211,59 +214,59 @@
},
"NodeViews": [
{
"ShowGeometry": true,
"Name": "Input",
"Id": "c3cf4c4917204a98aaad69f27d2efccc",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Name": "Input",
"ShowGeometry": true,
"Excluded": false,
"X": 70.5485530152981,
"Y": 41.3359231094885
},
{
"ShowGeometry": true,
"Name": "Output",
"Id": "444617634cbf4f8ca430249ffb661443",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Name": "Output",
"ShowGeometry": true,
"Excluded": false,
"X": 812.548553015298,
"Y": 98.3359231094885
},
{
"ShowGeometry": true,
"Name": "Input",
"Id": "b3d8bd06c0de4ee0b71bbd08d62b49f5",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Name": "Input",
"ShowGeometry": true,
"Excluded": false,
"X": 70.5485530152981,
"Y": 124.335923109488
},
{
"ShowGeometry": true,
"Name": "Input",
"Id": "b2e1ef1640cf41b2bc3111d2da3dfe42",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Name": "Input",
"ShowGeometry": true,
"Excluded": false,
"X": 70.5485530152981,
"Y": 207.335923109489
},
{
"ShowGeometry": true,
"Name": "Python Script",
"Id": "cd510746fdcd4cc3a2e1f69a6c8efa03",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Name": "Python Script",
"ShowGeometry": true,
"Excluded": false,
"X": 588.548553015298,
"Y": 98.3359231094885
}
],
"Annotations": [],
"X": 55.0,
"Y": 135.0,
"Zoom": 1.0
"X": 51.246469874767456,
"Y": 161.87133005900404,
"Zoom": 0.49618648738281262
}
}
8 changes: 5 additions & 3 deletions nodes/2.x/python/All Elements of Family Type+.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

def InstancesOfFamilyType(ft, doc):
collector = FilteredElementCollector(doc)
bic = System.Enum.ToObject(BuiltInCategory, ft.Category.Id.IntegerValue)
collector.OfCategory(bic)
return [x for x in collector.ToElements() if x.GetTypeId().IntegerValue == ft.Id.IntegerValue]
try:
bic = System.Enum.ToObject(BuiltInCategory, ft.Category.Id.IntegerValue)
collector.OfCategory(bic)
return [x for x in collector.ToElements() if x.GetTypeId().IntegerValue == ft.Id.IntegerValue]
except: return []

famtypes = UnwrapElement(IN[0])
inputdoc = UnwrapElement(IN[2])
Expand Down

0 comments on commit 50463d0

Please sign in to comment.