edit: sorry I was stupid, I didn’t save the python script between changes
doc.Actiview.Id and uidoc.Actiview.Id , there is no change between these 2 states
cordially
christian.stan
The other elements you’re seeing are Cameras, essentially view settings for other 3D views. You can filter them out with an ElementCategoryFilter() using the boolean overload. You could still have a few leftovers after that, depending on what all is in your view/project. You might also benefit from a WhereElementIsViewIndependent() filter as well.
This is why you have to be careful with true “all element” collectors. Just about everything in Revit is or has an element, often leaving you with a bunch of “extra” objects in your collector. The Dynamo node already filters out these extra categories.
Categories_ = doc.Settings.Categories
model_cat = []
for c in Categories_:
if c.CategoryType == CategoryType.Model:
model_cat.append(Revit.Elements.Category.ById(c.Id.IntegerValue))
else: continue
OUT = model_cat
this code works also, but can i map it like “Categories_.CurrentView”
Why are you wanting to filter out those elements? Isn’t that exactly what you want? You have roofs in your category filter and those elements are being included in the list. If you don’t want them just remove them from the filter.
import clr
import System
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
builtInCat = List[BuiltInCategory]()
Categories_ = doc.Settings.Categories
model_cat = []
for c in Categories_:
if c.CategoryType == CategoryType.Model:
model_cat.append(Revit.Elements.Category.ById(c.Id.IntegerValue))
else: continue
Categories_ = [x.Id for x in doc.Settings.Categories if x.CategoryType == CategoryType.Model]
catId = List[ElementId](Categories_)
Filter_ = ElementMulticategoryFilter(catId)
ModelElements = FilteredElementCollector(doc,doc.ActiveView.Id).WherePasses(Filter_).WhereElementIsNotElementType()
OUT = ModelElements
That’s where the WhereElementIsViewIndependent() filter comes in. View dependent elements are the elements specific to a view. View independent elements are the elements that exist in “model space” and are visible in all views (outside of filters and other view settings).
There are a handful of other view independent categories that are not model categories, but they don’t show up too often. It’s easier to filter them out rather than specify everything you want to include. This is where you can use the ElementCategoryFilter() with the boolean overload to excludeCamera category elements (and any others you may have).
The object type is unknown, which is probably an issue with the wrapper, but you can see python is returning the element.
Correct, but you’re only filtering out one of the two issues you’re dealing with. That is only removing the objects that are view dependent. There should only be one by default. All the additional elements you’re seeing are the Camera elements from other 3D views. You have to filter out that category with an additional filter.