Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andydandy74 committed Apr 5, 2024
1 parent 4ab4865 commit 45b5087
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nodes/2.x/Element.ResetSlabShape.dyf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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()

0 comments on commit 45b5087

Please sign in to comment.