Announcements
Welcome to the Revit Ideas Board! Before posting, please read the helpful tips here. Thank you for your Ideas!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select all in room

Select all in room

I use "select all" and "select all in view" often. If we could have a "select all in room" command that would be a huge time saver!

2 Comments
aaronrumple
Enthusiast

I suggest looking at pyRevit (or Dyanmo) and you can make all sorts of selection tools with just a few lines of code. pyRevit lets you quickly add on new buttons with no compiling of code.

This for instance grabs the room contents (even if you select more than one room) and adds them to your selection.

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument

from System.Collections.Generic import List

#######OK NOW YOU CAN CODE########

myData = UnwrapElement(IN[0])
myRooms = uidoc.Selection.GetElementIds()

myRoomList = []
for myRoom in myRooms:
	if isinstance(doc.GetElement(myRoom), Autodesk.Revit.DB.Architecture.Room):
		myRoomList.append(doc.GetElement(myRoom))
mySelection = FilteredElementCollector(doc).WhereElementIsViewIndependent()#WhereElementIsNotElementType().ToElements()
myRoomStuff = []
for room in myRoomList:
	for e in mySelection:
		try:
			if room.IsPointInRoom(e.Location.Point):
				myRoomStuff.append(e.Id)
		except:
			pass
uidoc.Selection.SetElementIds(List[ElementId](myRoomStuff))
myResult = myRoomStuff
MichaelWolff
Advisor

@aaronrumple Brilliant, but how do you get your code to run in pyRevit. All I get is an error message: "Name Error: name 'DocumentManager' is not defined". Is it, perhaps, a python script that is to run within Dynamo? Or a macro?

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea  

Forma Design Contest


Autodesk Design & Make Report