import traceback, clr
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import Selection
from Autodesk.Revit.UI import UIDocument, UIApplication
from Autodesk.Revit.DB.Structure import *
from pyrevit import forms
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
app = __revit__.Application
selection = uidoc.Selection
selected_element_ids = selection.GetElementIds()
elements = [doc.GetElement(e_id) for e_id in selected_element_ids]
if not elements:
forms.alert('No Elemenets were selected. Please Try Again', title=__title__, exitscript=True)
with Transaction(doc, 'Disallow Join') as t:
t.Start()
for el in elements:
el.Pinned = False
if el.Category.BuiltInCategory == BuiltInCategory.OST_StructuralFraming:
try:
StructuralFramingUtils.DisallowJoinAtEnd(el, 0)
StructuralFramingUtils.DisallowJoinAtEnd(el, 1)
except:
print('Could not Disallow Beam[{}]'.format(el.Id))
elif el.Category.BuiltInCategory == BuiltInCategory.OST_Walls:
try:
WallUtils.DisallowWallJoinAtEnd(el, 0)
WallUtils.DisallowWallJoinAtEnd(el, 1)
except:
print('Could not Disallow Wall[{}]'.format(el.Id))
t.Commit()