Hello @Ben_Osborne
i have tried to follow your outline for 2020 and have run into one issues.
I cant really work out how to set the rules, I have attached the script, but basically I try and create a rule that sets a typename- but it just doesnt want to work.
Blockquoteimport clr
clr.AddReference(‘System.Core’)
clr.AddReference(‘RhinoInside.Revit’)
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitAPIUI’)
from System import Enum
clr.AddReference(‘System’)
from System.Collections.Generic import List
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)
import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB
#from Autodesk.Revit.DB import *
DB is the data base module
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.ImportExtensions(RhinoInside.Revit.Convert.Geometry)
from RhinoInside.Revit.Convert.Geometry import UnitConverter
active Revit verison
REVIT_VERSION = Revit.ActiveUIApplication.Application.VersionNumber
access the active document object
doc = Revit.ActiveDBDocument
def show_warning(msg):
ghenv.Component.AddRuntimeMessage(RML.Warning, msg)
def show_error(msg):
ghenv.Component.AddRuntimeMessage(RML.Error, msg)
def show_remark(msg):
ghenv.Component.AddRuntimeMessage(RML.Remark, msg)
We want to get the element ID of the category
Get the built in type name paramter from curtain panels category
FINDNG CATEGR TYPES
CategoryFilter = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_CurtainWallPanels)
BuiltInCategory Enumeration
Create a list with one element of the category
Category_Elements =
for count, category in enumerate(CategoryFilter):
if count == 1:
break
Category_Elements.append(category)
Create a list
Category_ElementID_List2 =
get data from the category element
CategoryElement = Category_Elements[0]
Get the Element Id of the category
Category_ID = (CategoryElement.Id)
print (Category_ID)
Get tge element from the Category ID
Element = doc.GetElement(Category_ID)
Parameter_ElementID2= Element.get_Parameter(DB.BuiltInParameter.ALL_MODEL_TYPE_NAME).AsElementId()
print (Parameter_ElementID2)
Category_ElementID_List2.append(Parameter_ElementID2)
print (Category_ElementID_List2)
LOOKING ONLY AT CATEGORIES
Get element ID from curtain wall panels for the category and add it to a .net list
Category_ElementID_List =
Parameter_ElementID = DB.ElementId(DB.BuiltInCategory.OST_CurtainWallPanels)
print (Parameter_ElementID)
Category_ElementID_List.append(Parameter_ElementID)
print (Parameter_ElementID)
#cat_ids = [cat.Id for cat in category_set]
Convert Python list to .NET List
Stuck with List[ElementId](ids) - #4 by Yien
Solved: view filter by elementIds - Autodesk Community
FilterRule.ByRuleType input issues - #12 by crapai
col1 = ListDB.ElementId
cat_ids_valid = DB.ParameterFilterUtilities.RemoveUnfilterableCategories(col1)
print (cat_ids_valid)
Find type name (just to add)
Type_Name = CategoryElement.get_Parameter(DB.BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()
Set the rules
Rules_List =
ParameterFilterRuleFactory Class
rule_01 = DB.ParameterFilterRuleFactory.CreateContainsRule(Parameter_ElementID, “Yes”, False)
Rules_List.append(rule_01)
Convert single FitlerRule to List
rules = ListDB.FilterRule
HOW DO I MAKE THE RULES?
FilterRule.ByRuleType input issues - #17 by crapai
How to set a series Filter Rules using "OR (Any rule may be ture)" instead of "AND (All rules must be true)"? - #6 by Ben_Osborne
How to set a series Filter Rules using "OR (Any rule may be ture)" instead of "AND (All rules must be true)"? - #6 by Ben_Osborne
xFamName=DB.FilterStringRule(Parameter_ElementID2,DB.FilterStringBeginsWith(),“Blue”,False)
test=
test.Add(ElementParameterFilter(xFamName))
testlist=ListElementFilter
logical=LogicalAndFilter(testlist)
Redo this bit
t = DB.Transaction(doc, ‘update top constraint’)
t.Start()
#try:
ParameterFilterElement Class
fitler = DB.ParameterFilterElement.Create(doc, “Test Filter”, cat_ids_valid, logical)
#except:
#pass
t.Commit()