{ "Uuid": "c3a74c11-e0f8-4202-a540-322de1e33917", "IsCustomNode": false, "Description": "", "Name": "36_rotate_selection_z", "ElementResolver": { "ResolutionMap": {} }, "Inputs": [], "Outputs": [], "Nodes": [ { "ConcreteType": "CoreNodeModels.Input.StringInput, CoreNodeModels", "Id": "e31d9e95c4b1d9f17197b9be2f6bd22f", "NodeType": "StringInputNode", "Inputs": [], "Outputs": [ { "Id": "8a8d11361ce4d2d2c6d8095cef3ce56f", "Name": "", "Description": "String", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Replication": "Disabled", "Description": "Creates a string", "InputValue": "90" }, { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", "Code": "# -*- coding: utf-8 -*-\r\n# Micro — Rotar elementos seleccionados en planta alrededor del centro de su BoundingBox (eje Z).\r\n#\r\n# IN[0] : ángulo en grados sexagesimales (float), + = antihorario visto desde arriba\r\n#\r\n# Salida: conteo rotados / errores.\r\n\r\nimport sys\r\nimport math\r\n\r\nimport clr\r\nclr.AddReference('RevitAPI')\r\nclr.AddReference('RevitServices')\r\nfrom Autodesk.Revit.DB import Line, XYZ, ElementTransformUtils\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\n_ports = _dynamo_in_ports()\r\n\r\ntry:\r\n ang = float(_ports[0]) if len(_ports) > 0 and _ports[0] is not None else 0.0\r\nexcept Exception:\r\n ang = 0.0\r\n\r\nuidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument\r\nids = uidoc.Selection.GetElementIds()\r\nif ids is None or ids.Count == 0:\r\n OUT = ['Selecciona elementos en Revit.']\r\nelif abs(ang) < 1e-9:\r\n OUT = ['IN[0] ángulo distinto de cero.']\r\nelse:\r\n n = 0\r\n errs = []\r\n TransactionManager.Instance.EnsureInTransaction(doc)\r\n try:\r\n for eid in ids:\r\n el = doc.GetElement(eid)\r\n if el is None:\r\n continue\r\n bb = el.get_BoundingBox(None)\r\n if bb is None:\r\n errs.append(_ustr(eid.IntegerValue))\r\n continue\r\n cx = (bb.Min.X + bb.Max.X) / 2.0\r\n cy = (bb.Min.Y + bb.Max.Y) / 2.0\r\n cz = (bb.Min.Z + bb.Max.Z) / 2.0\r\n p0 = XYZ(cx, cy, cz)\r\n p1 = XYZ(cx, cy, cz + 1.0)\r\n axis = Line.CreateBound(p0, p1)\r\n try:\r\n ElementTransformUtils.RotateElement(doc, eid, axis, math.radians(ang))\r\n n += 1\r\n except Exception as ex:\r\n errs.append(_ustr(eid.IntegerValue) + ':' + _exc_str(ex))\r\n finally:\r\n TransactionManager.Instance.TransactionTaskDone()\r\n OUT = [n, 'elementos rotados'] + (errs[:10] if errs 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": "b56e6da4b412e8b862d359efee4b6ff0", "NodeType": "PythonScriptNode", "Inputs": [ { "Id": "d9e0d8d0a2e1b57866e6d4d2bf0373b0", "Name": "IN[0]", "Description": "IN[0] ángulo grados", "UsingDefaultValue": false, "Level": 2, "UseLevels": false, "KeepListStructure": false } ], "Outputs": [ { "Id": "d2b3adfed96211b2c956d6e26fa7f4f5", "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": "8a8d11361ce4d2d2c6d8095cef3ce56f", "End": "d9e0d8d0a2e1b57866e6d4d2bf0373b0", "Id": "e7d6162e33988cbf6b2632d582dbba13", "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": "e31d9e95c4b1d9f17197b9be2f6bd22f", "Name": "IN[0]", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 40, "Y": 220 }, { "Id": "b56e6da4b412e8b862d359efee4b6ff0", "Name": "RÜM 36 Rotar selección Z", "IsSetAsInput": false, "IsSetAsOutput": false, "Excluded": false, "ShowGeometry": true, "X": 520, "Y": 260 } ] } }