OD_Library/BIM/Dynamo Scripts/Read CSV/Read CSV.dyn

569 lines
No EOL
20 KiB
Text

{
"Uuid": "3c9d0464-8643-5ffe-96e5-ab1769818209",
"IsCustomNode": false,
"Description": "",
"Name": "Read CSV",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [
{
"Id": "8a2a5825305b4435a635d39b6b04b003",
"Name": "CSV File Path",
"Type": "string",
"Value": "..\\..\\..\\..\\OPENING DESIGN\\CTR\\Models & CAD\\Current Spreadsheets\\SHEET INDEX.csv",
"Description": "Allows you to select a file on the system to get its filename"
},
{
"Id": "3f21436c35a141d29dc668cb43c5c869",
"Name": "Refresh",
"Type": "boolean",
"Value": "false",
"Description": "Selection between a true and false."
},
{
"Id": "aee38477dfcd43838c0bf18fc41db905",
"Name": "Replace NewLine",
"Type": "boolean",
"Value": "true",
"Description": "Selection between a true and false."
},
{
"Id": "fa6a663b2db244e0b94559b5b0aa1e96",
"Name": "Replacement",
"Type": "string",
"Value": ", ",
"Description": "Creates a string."
}
],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "DSRevitNodesUI.Views, DSRevitNodesUI",
"SelectedIndex": 17,
"SelectedString": "SHEET INDEX",
"NodeType": "ExtensionNode",
"Id": "b9bb771dcfd34df2aeeb9d44732c64fd",
"Inputs": [],
"Outputs": [
{
"Id": "55d115ec29d74a3f96b571ebdc5fd647",
"Name": "Views",
"Description": "The selected Views",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "All views available in the current document."
},
{
"ConcreteType": "CoreNodeModels.Input.Filename, CoreNodeModels",
"HintPath": "C:\\Users\\regis\\OneDrive\\Documents\\Github\\OPENING DESIGN\\CTR\\Models & CAD\\Current Spreadsheets\\SHEET INDEX.csv",
"InputValue": "..\\..\\..\\..\\OPENING DESIGN\\CTR\\Models & CAD\\Current Spreadsheets\\SHEET INDEX.csv",
"NodeType": "ExtensionNode",
"Id": "8a2a5825305b4435a635d39b6b04b003",
"Inputs": [],
"Outputs": [
{
"Id": "dd66b6447fed49aeae8236864e70cc7a",
"Name": "",
"Description": "Filename",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Allows you to select a file on the system to get its filename"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore",
"NodeType": "FunctionNode",
"FunctionSignature": "DSCore.List.Deconstruct@var[]..[]",
"Id": "87cb1247b81d4eb8ae0f28aba9a6d838",
"Inputs": [
{
"Id": "708f7be1cbd0466ca09e250a9bafde2c",
"Name": "list",
"Description": "List to be split.\n\nvar[]..[]",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "79f6883ab71d4e3d9bc50c54aa4687d9",
"Name": "first",
"Description": "First item in the list.",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "3b1632e4f6f44830857b09d9e9dff429",
"Name": "rest",
"Description": "Rest of the list.",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Auto",
"Description": "Given a list, produces the first item in the list, and a new list containing all items except the first.\n\nList.Deconstruct (list: var[]..[]): var[]..[]"
},
{
"ConcreteType": "CoreNodeModels.Watch, CoreNodeModels",
"NodeType": "ExtensionNode",
"Id": "250a82aaad6c4f5aa02339ad8505c8d0",
"Inputs": [
{
"Id": "4c263fe86a9c45e8a5ef68968c4a4c8f",
"Name": "",
"Description": "Node to evaluate.",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "0e1084777a824c05bdc3eae5ae3f878b",
"Name": "",
"Description": "Watch contents.",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Visualize the output of node."
},
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "# Copyright(c) 2017, Dimitar Venkov\r\n# @5devene, dimitar.ven@gmail.com\r\n# www.badmonkeys.net\r\n# inspired by the Key Schedule node from arcni-lab.net\r\n\r\nimport clr\r\n\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference('RevitServices')\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\n\r\nks1 = UnwrapElement(IN[0])\r\nheaders = IN[1]\r\ndata = IN[2]\r\n\r\ntry:\r\n\tTransactionManager.Instance.EnsureInTransaction(doc)\r\n\tif any(isinstance(item, list) for item in data):\r\n\t\tcol_count = max(map(len, data) )\r\n\t\tif col_count != ks1.Definition.GetFieldCount() or col_count != len(headers):\r\n\t\t\traise Exception('Prepare the key schedule fields in\\nadvance, so that they match the data set.')\r\n\t\telse:\r\n\t\t\ttableData = ks1.GetTableData()\r\n\t\t\tsectionData = tableData.GetSectionData(SectionType.Body)\r\n\t\t\trow_count = sectionData.NumberOfRows\r\n\t\t\tfirstRows = 1\r\n\t\t\tif row_count != 1:\r\n\t\t\t\tst1 = SubTransaction(doc)\r\n\t\t\t\tst1.Start()\r\n\t\t\t\ttry:\r\n\t\t\t\t\tsectionData.RemoveRow(1)\r\n\t\t\t\texcept:\r\n\t\t\t\t\tfirstRows = 2\r\n\t\t\t\tst1.RollBack()\r\n\t\t\t\tst1.Dispose()\r\n\t\t\tif row_count - firstRows < len(data):\r\n\t\t\t\trowsToAdd = len(data) - row_count + firstRows\r\n\t\t\t\tfor _ in xrange(0, rowsToAdd):\r\n\t\t\t\t\tsectionData.InsertRow(0)\r\n\t\t\telse:\r\n\t\t\t\t# schedule when updating might already have too many rows \r\n\t\t\t\trowsToDelete = row_count - firstRows - len(data)\r\n\t\t\t\tfor i in xrange(row_count -1, row_count - rowsToDelete -1, -1):\r\n\t\t\t\t\tsectionData.RemoveRow(i)\r\n\t\t\tdoc.Regenerate()\r\n\t\t\trow_elems = FilteredElementCollector(doc, ks1.Id)\r\n\t\t\ti = 0\r\n\t\t\tfor e in row_elems:\r\n\t\t\t\tparams = e.ParametersMap\r\n\t\t\t\tfor j in xrange(col_count):\r\n\t\t\t\t\tparams[headers[j] ].Set(unicode(data[i][j]) )\r\n\t\t\t\ti += 1\r\n\tTransactionManager.Instance.TransactionTaskDone()\r\n\tOUT = \"Schedule set successfully.\"\r\nexcept Exception, ex:\r\n\tOUT = ex",
"VariableInputPorts": true,
"Id": "ae88e609d7dc404db280deca278f3027",
"Inputs": [
{
"Id": "b7170f221dc74b9b845a3ced781cc5a7",
"Name": "IN[0]",
"Description": "Input #0",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "2ad4672e33644a8aabcf47c7c112cb98",
"Name": "IN[1]",
"Description": "Input #1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "f1cd51b90f7147b2b9d1eacd357159ea",
"Name": "IN[2]",
"Description": "Input #2",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "a08b9d322f924b65b3f808bd0adeef39",
"Name": "IN[3]",
"Description": "Input #3",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "54d593a6a2c14cfdafc2d03b155faca9",
"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": "CoreNodeModels.Input.BoolSelector, CoreNodeModels",
"NodeType": "BooleanInputNode",
"InputValue": false,
"Id": "3f21436c35a141d29dc668cb43c5c869",
"Inputs": [],
"Outputs": [
{
"Id": "c08df7e2a7044c3f99e563d07a34611d",
"Name": "",
"Description": "Boolean",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Selection between a true and false."
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore",
"NodeType": "CodeBlockNode",
"Code": "/*\n\nDYNAMO VERSION: 1.3+\nREVIT VERSION: 2016+\n\nCreated by: Dimitar Venkov\nCreated on: 09/01/17\n\nModified by: Dimitar Venkov\nModified on: 12/03/18\n\nModified by:\nModified on:\n\nREQUIRED PACKAGES:\n------------------------------\n\nDESCRIPTION:\n------------------------------\n- All files must be encoded as UTF-8.\n\n- Make sure that you've created a Schedule beforehand\n and have added a new Text field (Fields > Add Parameter,\n Type of Parameter > Text) for each header name in the\n csv file.\n\n- As of the graph creation date, key schedule fields can\n not be created and added programatically through the API.\n\n- Before 'Run' the command make sure that the CSV file\n closed.\n\nISSUES:\n------------------------------\n\n*/;",
"Id": "c031061287e0467ca1432a7b4fbea68b",
"Inputs": [],
"Outputs": [],
"Replication": "Disabled",
"Description": "Allows for DesignScript code to be authored directly"
},
{
"ConcreteType": "CoreNodeModels.Input.BoolSelector, CoreNodeModels",
"NodeType": "BooleanInputNode",
"InputValue": true,
"Id": "aee38477dfcd43838c0bf18fc41db905",
"Inputs": [],
"Outputs": [
{
"Id": "69ce1f0dc90342dea16a8e7f4b514f86",
"Name": "",
"Description": "Boolean",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Selection between a true and false."
},
{
"ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels",
"NodeType": "StringInputNode",
"InputValue": ", ",
"Id": "fa6a663b2db244e0b94559b5b0aa1e96",
"Inputs": [],
"Outputs": [
{
"Id": "70f36a3f6f8c48949e00fc47347a32bc",
"Name": "",
"Description": "String",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Creates a string."
},
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "# Copyright(c) 2016, Bad Monkeys\n# www.badmonkeys.net\n\nimport clr\nimport System\npf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)\nimport sys\nsys.path.append('%s\\IronPython 2.7\\Lib' %pf_path)\nimport csv\n\ndef iterStream(csv_path):\n\twith System.IO.File.OpenText(csv_path) as f:\n\t\twhile not f.EndOfStream:\n\t\t\tyield f.ReadLine()\n\t\treturn\n\ncsv_path, to_replace, rep, _ = IN\ndata = csv.reader((iterStream(csv_path)))\nOUT = [[c.replace('\\n', rep) for c in row] for row in data] if to_replace else list(data)",
"VariableInputPorts": true,
"Id": "7a570d7a86fe4dcd973a5f07f098b47a",
"Inputs": [
{
"Id": "2df606021f6d4ccb85e01e928e30ddb7",
"Name": "IN[0]",
"Description": "Input #0",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "d96e75644644423a8fa943d22ffe37f0",
"Name": "IN[1]",
"Description": "Input #1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "4e57d4997c0540c9970f16d49628dafa",
"Name": "IN[2]",
"Description": "Input #2",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "3dfabc3d2dff4fcbaabfdac20d696340",
"Name": "IN[3]",
"Description": "Input #3",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "8d50bb315dfc4fed90af578b44729744",
"Name": "OUT",
"Description": "Result of the python script",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Runs an embedded IronPython script."
}
],
"Connectors": [
{
"Start": "55d115ec29d74a3f96b571ebdc5fd647",
"End": "b7170f221dc74b9b845a3ced781cc5a7",
"Id": "d1f7e25790194a36bd1128266fd52d3e"
},
{
"Start": "dd66b6447fed49aeae8236864e70cc7a",
"End": "2df606021f6d4ccb85e01e928e30ddb7",
"Id": "30be6de49f4147408f62471b0c810c6d"
},
{
"Start": "79f6883ab71d4e3d9bc50c54aa4687d9",
"End": "2ad4672e33644a8aabcf47c7c112cb98",
"Id": "74041b21fbc4417bb00594d3f714ddba"
},
{
"Start": "3b1632e4f6f44830857b09d9e9dff429",
"End": "f1cd51b90f7147b2b9d1eacd357159ea",
"Id": "bbd66cc6420a49f7b0907a193a048786"
},
{
"Start": "54d593a6a2c14cfdafc2d03b155faca9",
"End": "4c263fe86a9c45e8a5ef68968c4a4c8f",
"Id": "ce1977f069354351b9d14fb86346b482"
},
{
"Start": "c08df7e2a7044c3f99e563d07a34611d",
"End": "a08b9d322f924b65b3f808bd0adeef39",
"Id": "b9ce9499b92147a6a137a376163db677"
},
{
"Start": "c08df7e2a7044c3f99e563d07a34611d",
"End": "3dfabc3d2dff4fcbaabfdac20d696340",
"Id": "1b21f14ce7674d6882f5add1cbd91e97"
},
{
"Start": "69ce1f0dc90342dea16a8e7f4b514f86",
"End": "d96e75644644423a8fa943d22ffe37f0",
"Id": "41abedebcad14d42bfc5164d7f7a2cff"
},
{
"Start": "70f36a3f6f8c48949e00fc47347a32bc",
"End": "4e57d4997c0540c9970f16d49628dafa",
"Id": "250ead98462c441d8c88b3bb0c1aa3d2"
},
{
"Start": "8d50bb315dfc4fed90af578b44729744",
"End": "708f7be1cbd0466ca09e250a9bafde2c",
"Id": "828e1cf90c5b4164adca905306840c9c"
}
],
"Dependencies": [],
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": true,
"IsVisibleInDynamoLibrary": true,
"Version": "2.2.1.5175",
"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": [
{
"ShowGeometry": true,
"Name": "Schedule View",
"Id": "b9bb771dcfd34df2aeeb9d44732c64fd",
"IsSetAsInput": true,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1700.4674640102951,
"Y": 749.84324146989536
},
{
"ShowGeometry": true,
"Name": "CSV File Path",
"Id": "8a2a5825305b4435a635d39b6b04b003",
"IsSetAsInput": true,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1700.4674640102951,
"Y": 835.58155856132339
},
{
"ShowGeometry": true,
"Name": "List.Deconstruct",
"Id": "87cb1247b81d4eb8ae0f28aba9a6d838",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 2304.23941830452,
"Y": 855.896552452774
},
{
"ShowGeometry": true,
"Name": "Watch",
"Id": "250a82aaad6c4f5aa02339ad8505c8d0",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 2879.27291820314,
"Y": 817.218553272954
},
{
"ShowGeometry": true,
"Name": "KeySchedule.Populate",
"Id": "ae88e609d7dc404db280deca278f3027",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 2710.75543431257,
"Y": 819.328790154528
},
{
"ShowGeometry": true,
"Name": "Refresh",
"Id": "3f21436c35a141d29dc668cb43c5c869",
"IsSetAsInput": true,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1700.4674640102951,
"Y": 1063.6375768340654
},
{
"ShowGeometry": true,
"Name": "Code Block",
"Id": "c031061287e0467ca1432a7b4fbea68b",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1170.9815752587594,
"Y": 613.984683621985
},
{
"ShowGeometry": true,
"Name": "Replace NewLine",
"Id": "aee38477dfcd43838c0bf18fc41db905",
"IsSetAsInput": true,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1700.4674640102951,
"Y": 930.65434388178141
},
{
"ShowGeometry": true,
"Name": "Replacement",
"Id": "fa6a663b2db244e0b94559b5b0aa1e96",
"IsSetAsInput": true,
"IsSetAsOutput": false,
"Excluded": false,
"X": 1700.4674640102951,
"Y": 989.53406885646541
},
{
"ShowGeometry": true,
"Name": "csv.ReadUnicode",
"Id": "7a570d7a86fe4dcd973a5f07f098b47a",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 2161.0392173452205,
"Y": 855.02371619849009
}
],
"Annotations": [
{
"Id": "9614cf5b56944fa4a5877ed1d63f42a1",
"Title": "INPUT:",
"Nodes": [
"b9bb771dcfd34df2aeeb9d44732c64fd",
"8a2a5825305b4435a635d39b6b04b003",
"3f21436c35a141d29dc668cb43c5c869",
"aee38477dfcd43838c0bf18fc41db905",
"fa6a663b2db244e0b94559b5b0aa1e96"
],
"Left": 1690.4674640102951,
"Top": 719.84324146989536,
"Width": 376.99999999999977,
"Height": 411.79433536417,
"FontSize": 14.0,
"InitialTop": 749.84324146989536,
"InitialHeight": 458.79433536417,
"TextblockHeight": 20.0,
"Background": "#FF848484"
},
{
"Id": "e839ffb5792f4f5196fcb30a604643ef",
"Title": "filePath: string\r\nrepNewLine: bool\r\nreplacement: str\r\nRefresh: bool",
"Nodes": [],
"Left": 2033.7604683447,
"Top": 913.767755575526,
"Width": 0.0,
"Height": 0.0,
"FontSize": 36.0,
"InitialTop": 0.0,
"InitialHeight": 0.0,
"TextblockHeight": 0.0,
"Background": "#FFC1D676"
},
{
"Id": "5b8043e65ef44f9dbde5e8f5b8258a22",
"Title": "scheduleView: view\r\nheaders: string[]\r\ndata: string[][]\r\nrefresh: bool",
"Nodes": [],
"Left": 2561.83054685524,
"Top": 868.260847724039,
"Width": 0.0,
"Height": 0.0,
"FontSize": 36.0,
"InitialTop": 0.0,
"InitialHeight": 0.0,
"TextblockHeight": 0.0,
"Background": "#FFC1D676"
}
],
"X": -918.83580496190257,
"Y": -465.5376693323052,
"Zoom": 0.79585817346142507
}
}