Hi guys, i am trying to use this option IsolateElementsTemporary in Revit API. I already filtered theses elements and now i have a list with them but now how can i isolate them temporary?
Welcome, …
Please, do introduce yourself, and give us some context and code.
your are looking for that ?
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
selection = uidoc.Selection #type: Selection
isoView = doc.ActiveView
def uwlist(input):
result = input if isinstance(input, list) else [input]
return result
# 🛒 PickElemnetsbyRectangle
elements = selection.PickElementsByRectangle('Elements')
idlist = List[ElementId]()
for e in elements:
idlist.Add(e.Id)
# 🔓 Do some action in a Transaction
t = Transaction(doc,"isolate")
t.Start()
if len(elements) > 0:
isoView.IsolateElementsTemporary(idlist)
t.Commit()
# 🔒 done
i used a rectangle to isolate my elements.
Sorry, Jean. I should introduce myself before.
Hi everyone, I’m still learning how to use pyrevit and the revit API. I already know the basics enough about Python to start creating my own add-ins.
The context is that I work with piping in Revit and now I have many pipes, connections and accessories with the shared parameter LINE and P&ID filled in so I need to filter these elements more easily. this is the reason I asked about IsolateElementsTemporary.
Andreas, thank you!
it worked but as i am a rookie in Revit API i did not understand very well.
to complete the script i just needed to solve it > TypeError: expected ICollection[ElementId], got ElementId
i did as you showed but actually i would like to understand the different between Collection[ElementId] and ElementId. Could you help with it?
i know how hard it is to learn from scretch coding…
in my snippets there are not the moduls included… you have to import them as well.
here the code in total!
# -*- coding: utf-8 -*-
__title__ = "IsolateTemporary"
__doc__ = """Date = 29.12.2023
_____________________________________________________________________
Description:
isolate Elements by selection
_____________________________________________________________________
Author: """
# IMPORTS
#==================================================
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.UI.Selection import ObjectType, PickBoxStyle, Selection
# pyrevit
from pyrevit import forms, revit, script, DB
# .NET Imports
import clr
clr.AddReference("System")
from System.Collections.Generic import List
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
selection = uidoc.Selection #type: Selection
isoView = doc.ActiveView
# 🛒 PickElemnetsbyRectangle
elements = selection.PickElementsByRectangle('Elements')
idlist = List[ElementId]()
for e in elements:
idlist.Add(e.Id)
# 🔓 🔒 Do some action in a Transaction
with revit.Transaction("isolate"):
if len(elements) > 0:
isoView.IsolateElementsTemporary(idlist)