{ "Uuid": "b4e73c17-9033-4151-8ffd-b6955fb760aa", "IsCustomNode": false, "Description": "", "Name": "19_columns_on_grid_intersections", "ElementResolver": { "ResolutionMap": {} }, "Inputs": [], "Outputs": [], "Nodes": [ { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "7cb10627db294b087dd522acd490c9ff", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "53e074fbfb476ec6079aef3c3f5d9cf1", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "" }, { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "6893d0346c4b90f46e8705f96ebbea50", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "ec340d22d0baef322ec20a338bd1b7dd", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "" }, { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "fb372efb1c16192514d81ed747d605c8", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "492df7f2a3cbcab7dbf0059feb17b6cf", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "" }, { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", "Code": "# -*- coding: utf-8 -*-\r\n# 19 — Colocar columnas estructurales en intersecciones de rejillas (todas las parejas).\r\n#\r\n# IN[0] : nombre exacto del tipo de familia (FamilySymbol.Name) de columna estructural cargada\r\n# IN[1] : nombre del nivel base (Level.Name)\r\n# IN[2] : (opcional) nombre nivel superior para ajuste de offset (si no, altura por defecto del tipo)\r\n#\r\n# Salida: instancias creadas / errores.\r\n\r\nimport sys\r\n\r\nimport clr\r\nclr.AddReference('RevitAPI')\r\nclr.AddReference('RevitServices')\r\nfrom Autodesk.Revit.DB import (\r\n FilteredElementCollector,\r\n FamilySymbol,\r\n Level,\r\n Grid,\r\n XYZ,\r\n BuiltInCategory,\r\n Category,\r\n)\r\nfrom Autodesk.Revit.DB.Structure import StructuralType\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\n\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\n_PY3 = sys.version_info[0] >= 3\r\n\r\n\r\ndef _ustr(value):\r\n if value is None:\r\n return ''\r\n if _PY3:\r\n return str(value).strip()\r\n try:\r\n if isinstance(value, unicode):\r\n return value.strip()\r\n except NameError:\r\n pass\r\n return str(value).strip()\r\n\r\n\r\ndef _exc_str(ex):\r\n if _PY3:\r\n return str(ex)\r\n try:\r\n return unicode(ex)\r\n except NameError:\r\n return str(ex)\r\n\r\n\r\ndef _to_py_list(obj, max_index=256):\r\n if obj is None:\r\n return []\r\n if isinstance(obj, (list, tuple)):\r\n return list(obj)\r\n try:\r\n return list(obj)\r\n except TypeError:\r\n pass\r\n out = []\r\n for i in range(max_index):\r\n try:\r\n out.append(obj[i])\r\n except Exception:\r\n break\r\n return out\r\n\r\n\r\ndef _dynamo_in_ports():\r\n raw = globals().get('IN', [])\r\n ports = _to_py_list(raw, max_index=32)\r\n if len(ports) == 0 and raw is not None:\r\n tmp = []\r\n for i in range(32):\r\n try:\r\n tmp.append(raw[i])\r\n except Exception:\r\n break\r\n ports = tmp\r\n return ports\r\n\r\n\r\ndef _intersect_xy_line_line(p0, p1, q0, q1):\r\n x1, y1 = p0.X, p0.Y\r\n x2, y2 = p1.X, p1.Y\r\n x3, y3 = q0.X, q0.Y\r\n x4, y4 = q1.X, q1.Y\r\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\r\n if abs(den) < 1e-9:\r\n return None\r\n px = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / den\r\n py = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / den\r\n return px, py\r\n\r\n\r\n_ports = _dynamo_in_ports()\r\nsym_name = _ustr(_ports[0]) if len(_ports) > 0 else ''\r\nbase_lv_name = _ustr(_ports[1]) if len(_ports) > 1 else ''\r\n\r\nif not sym_name or not base_lv_name:\r\n OUT = ['Error: IN[0] tipo columna, IN[1] nivel base.']\r\nelse:\r\n col_cat = Category.GetCategory(doc, BuiltInCategory.OST_StructuralColumns)\r\n sym = None\r\n for s in FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements():\r\n if not s.IsActive:\r\n continue\r\n if col_cat is None or s.Category.Id != col_cat.Id:\r\n continue\r\n if _ustr(s.Name) == sym_name:\r\n sym = s\r\n break\r\n if sym is None:\r\n OUT = ['No se encontró FamilySymbol activo de columna con nombre: ' + sym_name]\r\n else:\r\n lv_map = {_ustr(l.Name): l for l in FilteredElementCollector(doc).OfClass(Level).ToElements()}\r\n if base_lv_name not in lv_map:\r\n OUT = ['Nivel base no encontrado: ' + base_lv_name]\r\n else:\r\n base_lv = lv_map[base_lv_name]\r\n z = base_lv.Elevation\r\n grids = list(FilteredElementCollector(doc).OfClass(Grid).ToElements())\r\n pts = []\r\n for i in range(len(grids)):\r\n for j in range(i + 1, len(grids)):\r\n c1 = grids[i].Curve\r\n c2 = grids[j].Curve\r\n if c1 is None or c2 is None:\r\n continue\r\n p0, p1 = c1.GetEndPoint(0), c1.GetEndPoint(1)\r\n q0, q1 = c2.GetEndPoint(0), c2.GetEndPoint(1)\r\n xy = _intersect_xy_line_line(p0, p1, q0, q1)\r\n if xy is None:\r\n continue\r\n pts.append(XYZ(xy[0], xy[1], z))\r\n created = []\r\n errors = []\r\n TransactionManager.Instance.EnsureInTransaction(doc)\r\n try:\r\n for pt in pts:\r\n try:\r\n col = doc.Create.NewFamilyInstance(pt, sym, base_lv, StructuralType.Column)\r\n created.append(col)\r\n except Exception as ex:\r\n errors.append(_exc_str(ex))\r\n finally:\r\n TransactionManager.Instance.TransactionTaskDone()\r\n OUT = created + (['ERRORES:'] + errors if errors else [])\r\n# --- RÜM: mensaje de cierre (URL en rum_platform_url.py) ---\r\ntry:\r\n import sys as _rum_sys\r\n _rum_root = r'c:\\RUM_Platform\\RUM_Tools\\Dynamo_Routines'\r\n if _rum_root not in _rum_sys.path:\r\n _rum_sys.path.insert(0, _rum_root)\r\n import rum_finalize as _rum_fin\r\n OUT = _rum_fin.apply(OUT)\r\nexcept Exception:\r\n pass\r\n", "Engine": "CPython3", "VariableInputPorts": true, "Id": "96a2761705b9bbd60aa8ad02ddc7b75c", "NodeType": "PythonScriptNode", "Inputs": [ { "Id": "13e229fb17d57a3ef3dfcdf1eac6e5b3", "Name": "IN[0]", "Description": "IN[0] nombre tipo columna", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false }, { "Id": "01984f9c6c4425cc5542e0394601296b", "Name": "IN[1]", "Description": "IN[1] nivel base", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false }, { "Id": "acf8e2991e82aeda50e34153a0247f0c", "Name": "IN[2]", "Description": "IN[2] nivel superior (opcional)", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Outputs": [ { "Id": "ead0b766d4e36bcb9aa968eb68421c9e", "Name": "OUT", "Description": "Result of the python script", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Runs an embedded Python script." } ], "Connectors": [ { "Start": "53e074fbfb476ec6079aef3c3f5d9cf1", "End": "13e229fb17d57a3ef3dfcdf1eac6e5b3", "Id": "5ee8b87c5c2ef1434d8f31acf6fdb9d6", "IsHidden": "False" }, { "Start": "ec340d22d0baef322ec20a338bd1b7dd", "End": "01984f9c6c4425cc5542e0394601296b", "Id": "3a15d0ea400408c9aa23dda4d46c4ab4", "IsHidden": "False" }, { "Start": "492df7f2a3cbcab7dbf0059feb17b6cf", "End": "acf8e2991e82aeda50e34153a0247f0c", "Id": "39833c3cc393731032fa09a5e59ae62f", "IsHidden": "False" } ], "Dependencies": [], "NodeLibraryDependencies": [], "EnableLegacyPolyCurveBehavior": true, "Thumbnail": "", "GraphDocumentationURL": null, "ExtensionWorkspaceData": [ { "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", "Name": "Properties", "Version": "3.3", "Data": {} }, { "ExtensionGuid": "DFBD9CC0-DB40-457A-939E-8C8555555A9D", "Name": "Generative Design", "Version": "8.2", "Data": {} } ], "Author": "RÜM", "Linting": { "activeLinter": "None", "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", "warningCount": 0, "errorCount": 0 }, "Bindings": [], "View": { "Dynamo": { "ScaleFactor": 1, "HasRunWithoutCrash": false, "IsVisibleInDynamoLibrary": true, "Version": "3.3.0.6316", "RunType": "Manual", "RunPeriod": "1000" }, "Camera": { "Name": "_Background Preview", "EyeX": 0, "EyeY": 0, "EyeZ": 10, "LookX": 0, "LookY": 0, "LookZ": 0, "UpX": 0, "UpY": 1, "UpZ": 0 }, "ConnectorPins": [], "Annotations": [], "X": 0, "Y": 0, "Zoom": 0.75, "NodeViews": [ { "Id": "7cb10627db294b087dd522acd490c9ff", "Name": "IN[0]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 40, "Y": 220 }, { "Id": "6893d0346c4b90f46e8705f96ebbea50", "Name": "IN[1]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 240, "Y": 220 }, { "Id": "fb372efb1c16192514d81ed747d605c8", "Name": "IN[2]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 440, "Y": 220 }, { "Id": "96a2761705b9bbd60aa8ad02ddc7b75c", "Name": "RÜM 19 Columnas en rejillas", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 520, "Y": 260 } ] } }