diff --git a/nodes/2.x/Element.ResetSlabShape.dyf b/nodes/2.x/Element.ResetSlabShape.dyf index b82e06a5..95c3480d 100644 --- a/nodes/2.x/Element.ResetSlabShape.dyf +++ b/nodes/2.x/Element.ResetSlabShape.dyf @@ -72,7 +72,7 @@ }, { "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", - "Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.GeometryConversion)\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\n\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\nslabs = UnwrapElement(IN[0])\r\nsuccess = []\r\n\r\ndef SlabShapeReset(slab):\r\n\tif hasattr(slab, \"SlapShapeEditor\"):\r\n\t\ttry:\r\n\t\t\tslab.SlabShapeEditor.ResetSlabShape()\r\n\t\t\treturn slab, True\r\n\t\texcept: return slab, False\r\n\tif hasattr(slab, \"GetSlapShapeEditor\"):\r\n\t\ttry:\r\n\t\t\tslab.GetSlabShapeEditor().ResetSlabShape()\r\n\t\t\treturn slab, True\r\n\t\texcept: return slab, False\r\n\telse: return slab, False\r\n\r\nTransactionManager.Instance.EnsureInTransaction(doc)\r\nif isinstance(IN[0], list): \r\n\tresults = [SlabShapeReset(x) for x in slabs]\r\n\tOUT = list(zip(*results))\r\nelse: OUT = SlabShapeReset(slabs)\r\nTransactionManager.Instance.TransactionTaskDone()", + "Code": "import clr\r\nclr.AddReference('RevitAPI')\r\nfrom Autodesk.Revit.DB import *\r\n\r\nclr.AddReference(\"RevitNodes\")\r\nimport Revit\r\nclr.ImportExtensions(Revit.GeometryConversion)\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager\r\nfrom RevitServices.Transactions import TransactionManager\r\n\r\ndoc = DocumentManager.Instance.CurrentDBDocument\r\nslabs = UnwrapElement(IN[0])\r\nsuccess = []\r\n\r\ndef SlabShapeReset(slab):\r\n\tsle = None\r\n\tif hasattr(slab, \"SlapShapeEditor\"): sle = slab.SlabShapeEditor\r\n\telif hasattr(slab, \"GetSlabShapeEditor\"): sle = slab.GetSlabShapeEditor()\r\n\tif sle:\r\n\t\ttry:\r\n\t\t\tsle.ResetSlabShape()\r\n\t\t\treturn slab, True\r\n\t\texcept: return slab, False\r\n\telse: return slab, False\r\n\r\nTransactionManager.Instance.EnsureInTransaction(doc)\r\nif isinstance(IN[0], list): \r\n\tresults = [SlabShapeReset(x) for x in slabs]\r\n\tOUT = list(zip(*results))\r\nelse: OUT = SlabShapeReset(slabs)\r\nTransactionManager.Instance.TransactionTaskDone()", "Engine": "IronPython2", "EngineName": "IronPython2", "VariableInputPorts": true, diff --git a/nodes/2.x/python/Roof.ResetSlabShape.py b/nodes/2.x/python/Element.ResetSlabShape.py similarity index 50% rename from nodes/2.x/python/Roof.ResetSlabShape.py rename to nodes/2.x/python/Element.ResetSlabShape.py index 3f8f2658..7bd32094 100644 --- a/nodes/2.x/python/Roof.ResetSlabShape.py +++ b/nodes/2.x/python/Element.ResetSlabShape.py @@ -15,15 +15,20 @@ slabs = UnwrapElement(IN[0]) success = [] -TransactionManager.Instance.EnsureInTransaction(doc) -for slab in slabs: - objtype = slab.GetType().ToString() - if objtype == "Autodesk.Revit.DB.FootPrintRoof" or objtype == "Autodesk.Revit.DB.Floor": +def SlabShapeReset(slab): + sle = None + if hasattr(slab, "SlapShapeEditor"): sle = slab.SlabShapeEditor + elif hasattr(slab, "GetSlabShapeEditor"): sle = slab.GetSlabShapeEditor() + if sle: try: - slab.SlabShapeEditor.ResetSlabShape() - success.append(True) - except: success.append(False) - else: success.append(False) -TransactionManager.Instance.TransactionTaskDone() + sle.ResetSlabShape() + return slab, True + except: return slab, False + else: return slab, False -OUT = (slabs, success) \ No newline at end of file +TransactionManager.Instance.EnsureInTransaction(doc) +if isinstance(IN[0], list): + results = [SlabShapeReset(x) for x in slabs] + OUT = list(zip(*results)) +else: OUT = SlabShapeReset(slabs) +TransactionManager.Instance.TransactionTaskDone() \ No newline at end of file