Try to delete wall sweep from wall compound structure but not solved. Does anyone solution with that?

from Autodesk.Revit.DB import *
from pyrevit import revit, DB, script

# Get the current document
doc = revit.doc
output = script.get_output()

# Start a transaction
t = Transaction(doc, "Clear Wall Sweeps")
t.Start()

try:
    # Collect all walls in the document
    wall_collector = FilteredElementCollector(doc) \
        .OfClass(Wall) \
        .WhereElementIsNotElementType()  # Exclude Wall Types, only get wall instances

    # Iterate through all walls
    for wall in wall_collector:
        # Access the wall type and compound structure
        wall_type = wall.WallType
        compound_structure = wall_type.GetCompoundStructure()

        if compound_structure is not None:
            sweeps_removed = 0  # Replace with actual logic for sweeps
            output.print_md("Sweeps removed from wall: {}".format(sweeps_removed))

    t.Commit()
    output.print_md("Transaction committed successfully!")
except Exception as e:
    t.RollBack()
    output.print_md("Error occurred: {}".format(e))


Gets the iList of wall sweeps in the wall type.

Wall..GetCompoundStructure().GetWallSweepsInfo(WallSweepType.Sweep)

``
Remove sweep from wall type.

CompoundStructure.RemoveWallSweep(sweep)

Removes all wall sweeps for a selected (in browser) wall type.

t = Transaction(doc, "Remove Sweeps")
t.Start()
selection = uidoc.Selection.GetElementIds()
for id in selection:
	wtype = doc.GetElement(id)
	cs = wtype.GetCompoundStructure()
	wsinfo = cs.GetWallSweepsInfo(WallSweepType.Sweep)
	n = 0
	for s in wsinfo:
		cs.RemoveWallSweep(s.WallSweepType, s.Id)
	wtype.SetCompoundStructure(cs)
t.Commit()

Removes all reveals for selected (in browswer) wall type.

type or paste code heret = Transaction(doc, "Remove Sweeps")
t.Start()
selection = uidoc.Selection.GetElementIds()
for id in selection:
	wtype = doc.GetElement(id)
	cs = wtype.GetCompoundStructure()
	wsinfo = cs.GetWallSweepsInfo(WallSweepType.Reveal)
	n = 0
	for s in wsinfo:
		cs.RemoveWallSweep(s.WallSweepType, s.Id)
	wtype.SetCompoundStructure(cs)
t.Commit()
2 Likes