{ "Uuid": "778e001aa106449f9a0dffb65f5ef7ac", "IsCustomNode": false, "Description": "", "Name": "33_room_name_to_element", "ElementResolver": { "ResolutionMap": {} }, "Inputs": [], "Outputs": [], "Nodes": [ { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "7ce151b0ad0548c0afe3a48b4c3f0e00", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "d015fcb5b3c1477bb30a81ed5af15fc2", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "Furniture" }, { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "16c296e530dd4c21acb975cad099db99", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "6e749d2c1d204c9cb776d636d38b995e", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "Comments" }, { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "811eed05267e4fc1bd752b0d7cfa7fd5", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "a503533a097147039b4244be392fead5", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "BOTH" }, { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "34d7c7d6ddfa4ace9ec16a249e2989e7", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "e73816e0d9de414e9418c4696265290d", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "False" }, { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", "Code": "# -*- coding: utf-8 -*-\r\n# Micro — Si el punto de inserción está en una habitación, copia número/nombre al parámetro.\r\n#\r\n# IN[0] : categoría (ej. Furniture, Generic Models)\r\n# IN[1] : parámetro de texto destino\r\n# IN[2] : NUMBER | NAME | BOTH (BOTH = \"Número - Nombre\")\r\n# IN[3] : True = solo selección\r\n#\r\n# Salida: conteo modificado.\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 BuiltInCategory,\r\n BuiltInParameter,\r\n StorageType,\r\n Room,\r\n LocationPoint,\r\n)\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\n\r\n_PY3 = sys.version_info[0] >= 3\r\ndoc = DocumentManager.Instance.CurrentDBDocument\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 _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 _as_bool(val):\r\n if val is None:\r\n return False\r\n if isinstance(val, bool):\r\n return val\r\n if isinstance(val, int):\r\n return bool(val)\r\n s = _ustr(val).lower()\r\n if s in ('false', 'falso', '0', 'no', 'n', '', 'off'):\r\n return False\r\n if s in ('true', 'verdadero', '1', 'yes', 'si', 'sí', 'on'):\r\n return True\r\n try:\r\n return bool(int(float(s)))\r\n except Exception:\r\n return bool(val)\r\n\r\n\r\ndef _bic(cat_str):\r\n try:\r\n s = _ustr(cat_str).strip()\r\n name = s if s.startswith('OST_') else 'OST_' + s.replace(' ', '')\r\n return getattr(BuiltInCategory, name)\r\n except Exception:\r\n return None\r\n\r\n\r\ndef _elements(cat, use_sel):\r\n if _as_bool(use_sel):\r\n uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument\r\n ids = uidoc.Selection.GetElementIds()\r\n return [doc.GetElement(i) for i in ids]\r\n bic = _bic(cat)\r\n if bic is None:\r\n return []\r\n return list(FilteredElementCollector(doc).OfCategory(bic).WhereElementIsNotElementType().ToElements())\r\n\r\n\r\ndef _room_at_point(pt):\r\n for r in FilteredElementCollector(doc).OfClass(Room).ToElements():\r\n try:\r\n if r.Location is not None and r.IsPointInRoom(pt):\r\n return r\r\n except Exception:\r\n continue\r\n return None\r\n\r\n\r\n_ports = _dynamo_in_ports()\r\ncat = _ustr(_ports[0]) if len(_ports) > 0 else ''\r\npname = _ustr(_ports[1]) if len(_ports) > 1 else ''\r\nmode = _ustr(_ports[2]).upper() if len(_ports) > 2 else 'BOTH'\r\nuse_sel = _as_bool(_ports[3]) if len(_ports) > 3 else False\r\n\r\nif not pname or (not use_sel and not cat) or mode not in ('NUMBER', 'NAME', 'BOTH'):\r\n OUT = ['Error: categoría/selección, parámetro, modo NUMBER|NAME|BOTH.']\r\nelse:\r\n n = 0\r\n TransactionManager.Instance.EnsureInTransaction(doc)\r\n try:\r\n for el in _elements(cat, use_sel):\r\n if el is None:\r\n continue\r\n loc = el.Location\r\n if not isinstance(loc, LocationPoint):\r\n continue\r\n p = el.LookupParameter(pname)\r\n if p is None or p.IsReadOnly or p.StorageType != StorageType.String:\r\n continue\r\n rm = _room_at_point(loc.Point)\r\n if rm is None:\r\n continue\r\n num = rm.Number or ''\r\n np = rm.get_Parameter(BuiltInParameter.ROOM_NAME)\r\n if np is not None and np.HasValue:\r\n rname = np.AsString() or ''\r\n else:\r\n rname = _ustr(rm.Name)\r\n if mode == 'NUMBER':\r\n val = _ustr(num).strip()\r\n elif mode == 'NAME':\r\n val = _ustr(rname).strip()\r\n else:\r\n val = (_ustr(num).strip() + ' - ' + _ustr(rname).strip()).strip(' -')\r\n try:\r\n p.Set(val)\r\n n += 1\r\n except Exception:\r\n pass\r\n finally:\r\n TransactionManager.Instance.TransactionTaskDone()\r\n OUT = [n, 'elementos']\r\n\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": "090c0377af9d4780b7175747adf3ec7d", "NodeType": "PythonScriptNode", "Inputs": [ { "Id": "244c0f2f002242c49e9bb2cd2e6553a3", "Name": "IN[0]", "Description": "IN[0] Categoría", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false }, { "Id": "c811516a38304a02b2ee8a32217eefbd", "Name": "IN[1]", "Description": "IN[1] Parámetro texto", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false }, { "Id": "b0b1ce5bba99472081e5f453b992d429", "Name": "IN[2]", "Description": "IN[2] NUMBER|NAME|BOTH", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false }, { "Id": "2d64caad9676463e9d911563e5957e8e", "Name": "IN[3]", "Description": "IN[3] Solo selección True/False", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Outputs": [ { "Id": "d6471c7426714f16b769c727dab68fdf", "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": "d015fcb5b3c1477bb30a81ed5af15fc2", "End": "244c0f2f002242c49e9bb2cd2e6553a3", "Id": "67f5b1a111564fb1aa11c84a3ca2034d", "IsHidden": "False" }, { "Start": "6e749d2c1d204c9cb776d636d38b995e", "End": "c811516a38304a02b2ee8a32217eefbd", "Id": "f8ccca09769443f3a34448822f5a97af", "IsHidden": "False" }, { "Start": "a503533a097147039b4244be392fead5", "End": "b0b1ce5bba99472081e5f453b992d429", "Id": "62d2b068f3bc4ad3b8f451328266374a", "IsHidden": "False" }, { "Start": "e73816e0d9de414e9418c4696265290d", "End": "2d64caad9676463e9d911563e5957e8e", "Id": "665b05068b884aa8837c731ce59e84cb", "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": [], "NodeViews": [ { "Id": "7ce151b0ad0548c0afe3a48b4c3f0e00", "Name": "IN[0]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 40, "Y": 220 }, { "Id": "16c296e530dd4c21acb975cad099db99", "Name": "IN[1]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 240, "Y": 220 }, { "Id": "811eed05267e4fc1bd752b0d7cfa7fd5", "Name": "IN[2]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 440, "Y": 220 }, { "Id": "34d7c7d6ddfa4ace9ec16a249e2989e7", "Name": "IN[3]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 640, "Y": 220 }, { "Id": "090c0377af9d4780b7175747adf3ec7d", "Name": "RUM_33_RoomNameToElement", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 920, "Y": 360 } ], "Annotations": [], "X": 0, "Y": 0, "Zoom": 0.75 } }