Select certain family types only rather than all elements in view


#1

Hi all

I am trying to find an easy way to filter down my lookup elements to only include those family types shown.

Is there an easier way to do this that i am not thinking off?

Any help would be greatly appreciated


#2

adding to this, the family types are of different categories ( pipe fittings, sprinklers and pipe accessories)


#3

I have this collector by type…But it gets from all elements in project…Modify the code by adding the Active viewID argument to the collector and you can select only specific types from view.And it also selects the element for you in the revit workspace

import clr

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
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application


select = []
uisel = uidoc.Selection
result = []

type = IN[0]

selectelements = IN[1]

#Preparing input from dynamo to revit

collector = FilteredElementCollector(doc)

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)



Selectedtype = collector.OfClass(type).ToElements()

if selectelements == True:

	for i in Selectedtype:
	
		select.append(i.Id)
		Icollection = List[ElementId](select)
		uisel.SetElementIds(Icollection)
		result.append("select")
		
	else:

		result=null




		
				
TransactionManager.Instance.TransactionTaskDone()


OUT = Selectedtype