diff --git a/README.md b/README.md index 2bd4184..dbc0470 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,16 @@ Clockwork *Deprecated nodes as prerequeites, see 1.x branch* +### ConvertToMeter ✅ + +Convert from Revit display unit to meter + +Python script based on Document.LengthDisplayUnit from Data-Shapes. + +### GetDisplacedElements ✅ + +Lists all displaced elements of a view. + ### ReplaceFollowingElements ✅ Replace same elements follow each other diff --git a/nodes/ConvertToMeter.dyf b/nodes/ConvertToMeter.dyf new file mode 100644 index 0000000..843475c --- /dev/null +++ b/nodes/ConvertToMeter.dyf @@ -0,0 +1,278 @@ +{ + "Uuid": "0a580cf8-9c53-48b1-8a4d-1acb49d472b5", + "IsCustomNode": true, + "Category": "infeeeee.Revit.Units", + "Description": "Convert from Revit display unit to meter", + "Name": "ConvertToMeter", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore", + "NodeType": "OutputNode", + "ElementResolver": null, + "Symbol": "Meter", + "Id": "254f4ae16e5d42c1bf4d9970684efbde", + "Inputs": [ + { + "Id": "86a6d4e81dae4118b323a5b14e5a448f", + "Name": "", + "Description": "", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [], + "Replication": "Disabled", + "Description": "A function output, use with custom nodes" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore", + "NodeType": "InputNode", + "Parameter": { + "Name": "length", + "TypeName": "double", + "TypeRank": 0, + "DefaultValue": null, + "Description": "" + }, + "Id": "1cfe174d311b4f93bc294d02f4152ac2", + "Inputs": [], + "Outputs": [ + { + "Id": "b501676612b6478dbf2e72025bb27c40", + "Name": "", + "Description": "Symbol", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "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" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "x;\n\ny = [Imperative]\n{\nif (x == \"Millimeters\") {\nreturn = 1000;\n}\nelse if (x == \"Centimeters\" ) {\nreturn = 100;\n}\nelse if (x == \"Decimeters\" ) {\nreturn = 10;\n}\nelse if (x == \"Decimal feet\" ||\n\tx == \"Feet and fractional inches\" ) {\nreturn = 3.280839895;\n}\nelse if (x == \"Decimal inches\" ||\n\tx == \"Fractional inches\" ) {\nreturn = 39.37007874;\n}\nelse {\nreturn = 1;\n}\n};", + "Id": "e5530a5429824985b5207815f0d7455a", + "Inputs": [ + { + "Id": "3c4f4e2261b645c6822825341f259085", + "Name": "x", + "Description": "x", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "1929e12ffa7c4b6c9a49b22833621326", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "b01f68faaa6c4d789650531ec589f7b4", + "Name": "", + "Description": "y", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", + "NodeType": "PythonScriptNode", + "Code": "#Copyright (c) Data Shapes, 2018\n#Data-Shapes www.data-shapes.net , elayoubi.mostafa@data-shapes.io @data_shapes\n\nimport clr\nclr.AddReference('RevitAPI')\nfrom Autodesk.Revit.DB import*\nclr.AddReference('RevitServices')\nfrom RevitServices.Persistence import DocumentManager\n\ndoc = DocumentManager.Instance.CurrentDBDocument\nFOptions = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length)\nUIunit = FOptions.DisplayUnits\nShow = UIunit.ToString().split('_')\ndel Show[0]\nShow = ' '.join([s.title() for s in Show])\n\nOUT = Show", + "VariableInputPorts": true, + "Id": "dd4764e1aa794811950feebef8f6026d", + "Inputs": [], + "Outputs": [ + { + "Id": "540376c1c00a42de825c63aa3cbfb101", + "Name": "OUT", + "Description": "Result of the python script", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Runs an embedded IronPython script." + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "a/b;", + "Id": "415b231044aa4b718005da23768919b2", + "Inputs": [ + { + "Id": "2eeeb6df0f15483aaa15fcf8d35df6d2", + "Name": "a", + "Description": "a", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "d05ade86d5af42609323c66d5c67ff7f", + "Name": "b", + "Description": "b", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "ef4caa4485c94a94962f59e58fb152e4", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + } + ], + "Connectors": [ + { + "Start": "b501676612b6478dbf2e72025bb27c40", + "End": "2eeeb6df0f15483aaa15fcf8d35df6d2", + "Id": "7f0d019d2293492eb47afa17d0f8319b" + }, + { + "Start": "b01f68faaa6c4d789650531ec589f7b4", + "End": "d05ade86d5af42609323c66d5c67ff7f", + "Id": "59e6c37518b341bc800ed06f50848cb6" + }, + { + "Start": "540376c1c00a42de825c63aa3cbfb101", + "End": "3c4f4e2261b645c6822825341f259085", + "Id": "d73cf932feb44ee1890e9f81903f4399" + }, + { + "Start": "ef4caa4485c94a94962f59e58fb152e4", + "End": "86a6d4e81dae4118b323a5b14e5a448f", + "Id": "63fba3807fb242e8b14de64b51bc9644" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": false, + "IsVisibleInDynamoLibrary": true, + "Version": "2.3.0.5885", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -100626.82073850936, + "EyeY": 370777.98985935876, + "EyeZ": 186476.80299970528, + "LookX": 82993.109801009356, + "LookY": -378777.98985935876, + "LookZ": -203476.31862470528, + "UpX": 0.27844678833061143, + "UpY": 0.67559020761566158, + "UpZ": -0.682675074572229 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Output", + "Id": "254f4ae16e5d42c1bf4d9970684efbde", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 898.52380216322445, + "Y": 533.53666666666663 + }, + { + "ShowGeometry": true, + "Name": "Input", + "Id": "1cfe174d311b4f93bc294d02f4152ac2", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 228.5238021632245, + "Y": 775.53666666666663 + }, + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "e5530a5429824985b5207815f0d7455a", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 228.5238021632245, + "Y": 278.17666666666668 + }, + { + "ShowGeometry": true, + "Name": "Python Script", + "Id": "dd4764e1aa794811950feebef8f6026d", + "IsSetAsInput": true, + "IsSetAsOutput": false, + "Excluded": false, + "X": 34.5238021632245, + "Y": 273.96333333333337 + }, + { + "ShowGeometry": true, + "Name": "Code Block", + "Id": "415b231044aa4b718005da23768919b2", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 715.52380216322445, + "Y": 537.75 + } + ], + "Annotations": [ + { + "Id": "552a6cdd76d0428a87a2adb9e46fdd5c", + "Title": "Based on Document.LengthDisplayUnit from Data-Shapes", + "Nodes": [], + "Left": -13.338278931750665, + "Top": 156.92878338278945, + "Width": 0.0, + "Height": 0.0, + "FontSize": 36.0, + "InitialTop": 0.0, + "InitialHeight": 0.0, + "TextblockHeight": 0.0, + "Background": "#FFC1D676" + } + ], + "X": 142.11249999999995, + "Y": 177.66249999999997, + "Zoom": 0.8425 + } +} \ No newline at end of file diff --git a/nodes/GetDisplacedElements.dyf b/nodes/GetDisplacedElements.dyf new file mode 100644 index 0000000..3e3b526 --- /dev/null +++ b/nodes/GetDisplacedElements.dyf @@ -0,0 +1,215 @@ +{ + "Uuid": "879adabd-807d-426e-b91c-2aa23f50d699", + "IsCustomNode": true, + "Category": "infeeeee.Revit.Views", + "Description": "Get all displaced elements of a view", + "Name": "GetDisplacedElements", + "ElementResolver": { + "ResolutionMap": { + "List": { + "Key": "List", + "Value": "BuiltIn.ds" + } + } + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", + "NodeType": "PythonScriptNode", + "Code": "import clr\r\n\r\nclr.AddReference('ProtoGeometry')\r\nfrom Autodesk.DesignScript.Geometry import *\r\n\r\nclr.AddReference(\"RevitAPI\")\r\nfrom Autodesk.Revit.DB import DisplacementElement\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\n\r\nif isinstance(IN[0], list):\r\n\t\tviews = UnwrapElement(IN[0])\r\nelse:\r\n\t\tviews = [UnwrapElement(IN[0])]\r\n\r\nids = []\r\n\r\nfor j in views:\r\n\tids.append(DisplacementElement.GetDisplacedElementIds(j))\r\n\t\r\nallelems = []\r\nfor x in ids:\r\n\telem = []\r\n\tfor y in x:\r\n\t\telem.append(doc.GetElement(y))\r\n\tallelems.append(elem)\t\r\n\t\r\nOUT = allelems", + "VariableInputPorts": true, + "Id": "fb5e3776eaf44697947a2ac47df2a7ca", + "Inputs": [ + { + "Id": "f749d028abef4c93a60d246c71024381", + "Name": "IN[0]", + "Description": "Input #0", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "1c614b4aee2543e7bc8f38baff0dd697", + "Name": "OUT", + "Description": "Result of the python script", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Runs an embedded IronPython script." + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore", + "NodeType": "InputNode", + "Parameter": { + "Name": "view", + "TypeName": "var", + "TypeRank": 0, + "DefaultValue": null, + "Description": "" + }, + "Id": "181cfb7a84b541a58b75fe33b740f224", + "Inputs": [], + "Outputs": [ + { + "Id": "bb41ca2cbbe64d2980f2c8a4eadf8dbe", + "Name": "", + "Description": "Symbol", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "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" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore", + "NodeType": "OutputNode", + "ElementResolver": null, + "Symbol": "elements", + "Id": "80fe6c1aa61d42449d9638948725b51f", + "Inputs": [ + { + "Id": "edb0ddd102b04f36be9fa3ca50dc0bb2", + "Name": "", + "Description": "", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [], + "Replication": "Disabled", + "Description": "A function output, use with custom nodes" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "a[0];", + "Id": "2e52c87d7a964622ba11ff2bda151662", + "Inputs": [ + { + "Id": "d09e7e576db140989f39141de8800d32", + "Name": "a", + "Description": "a", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "c48015a2574f491db34a4badd2f69b4b", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + } + ], + "Connectors": [ + { + "Start": "1c614b4aee2543e7bc8f38baff0dd697", + "End": "d09e7e576db140989f39141de8800d32", + "Id": "43804d98f46241838f6dc276c9777e50" + }, + { + "Start": "bb41ca2cbbe64d2980f2c8a4eadf8dbe", + "End": "f749d028abef4c93a60d246c71024381", + "Id": "ce62ce5cdbec4a8b97ed77cea2baf5a9" + }, + { + "Start": "c48015a2574f491db34a4badd2f69b4b", + "End": "edb0ddd102b04f36be9fa3ca50dc0bb2", + "Id": "00bab7b3876041cba7739c4ba3ddb570" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": false, + "IsVisibleInDynamoLibrary": true, + "Version": "2.3.0.5885", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "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 + }, + "NodeViews": [ + { + "Id": "fb5e3776eaf44697947a2ac47df2a7ca", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Python Script", + "ShowGeometry": true, + "Excluded": false, + "X": 567.77576982463927, + "Y": 559.55697114938823 + }, + { + "Id": "181cfb7a84b541a58b75fe33b740f224", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Input", + "ShowGeometry": true, + "Excluded": false, + "X": 363.77576982463927, + "Y": 559.55697114938823 + }, + { + "Id": "80fe6c1aa61d42449d9638948725b51f", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Output", + "ShowGeometry": true, + "Excluded": false, + "X": 981.77576982463927, + "Y": 559.55697114938823 + }, + { + "Id": "2e52c87d7a964622ba11ff2bda151662", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Name": "Code Block", + "ShowGeometry": true, + "Excluded": false, + "X": 791.77576982463927, + "Y": 563.7703044827216 + } + ], + "Annotations": [], + "X": -57.229111179073413, + "Y": 0.0398473309929841, + "Zoom": 1.0141327329164149 + } +} \ No newline at end of file diff --git a/nodes/GetDisplacedElements.py b/nodes/GetDisplacedElements.py new file mode 100644 index 0000000..f969780 --- /dev/null +++ b/nodes/GetDisplacedElements.py @@ -0,0 +1,32 @@ +import clr + +clr.AddReference('ProtoGeometry') +from Autodesk.DesignScript.Geometry import * + +clr.AddReference("RevitAPI") +from Autodesk.Revit.DB import DisplacementElement + +clr.AddReference("RevitServices") +import RevitServices +from RevitServices.Persistence import DocumentManager +from RevitServices.Transactions import TransactionManager +doc = DocumentManager.Instance.CurrentDBDocument + +if isinstance(IN[0], list): + views = UnwrapElement(IN[0]) +else: + views = [UnwrapElement(IN[0])] + +ids = [] + +for j in views: + ids.append(DisplacementElement.GetDisplacedElementIds(j)) + +allelems = [] +for x in ids: + elem = [] + for y in x: + elem.append(doc.GetElement(y)) + allelems.append(elem) + +OUT = allelems \ No newline at end of file