Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
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
@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?