From c4224d68a4d4e1cda3c17bdb21712522a9fbba69 Mon Sep 17 00:00:00 2001 From: Wurschdhaud Date: Fri, 10 Oct 2025 20:06:19 +0200 Subject: [PATCH] compat for Revit 2026 --- lib/pychilizer/database.py | 15 ++++++++------- lib/pychilizer/select.py | 7 +++++-- .../Dim Grids.pushbutton/script.py | 5 ++++- .../Dim Levels.pushbutton/script.py | 5 ++++- .../Toggle grid bubbles.pushbutton/script.py | 5 ++++- .../Toggle level bubbles.pushbutton/script.py | 5 ++++- .../Legend by Excel.pushbutton/script.py | 4 +++- .../Renumber by spline.pushbutton/script.py | 9 ++++++--- .../InPlace to Loadable.pushbutton/script.py | 4 +++- .../List by Design Option.pushbutton/script.py | 4 +++- .../List by Workset.pushbutton/script.py | 4 +++- .../Filters by Value.pushbutton/script.py | 5 ++++- .../Pick Plan Regions.pushbutton/script.py | 5 ++++- .../List Walls.pushbutton/walltypesconfig.py | 5 ++++- .../Worksets.panel/Workset3D.pushbutton/script.py | 9 +++++---- 15 files changed, 64 insertions(+), 27 deletions(-) diff --git a/lib/pychilizer/database.py b/lib/pychilizer/database.py index 21c33f1..4edc021 100644 --- a/lib/pychilizer/database.py +++ b/lib/pychilizer/database.py @@ -2,6 +2,7 @@ from pyrevit import revit, DB, script, forms, HOST_APP, coreutils, PyRevitException from pyrevit.framework import List +from pyrevit.compat import get_elementid_value_func from collections import defaultdict from pychilizer import units from pyrevit.revit.db import query @@ -9,7 +10,7 @@ import clr import System - +get_elementid_value = get_elementid_value_func() BIC = DB.BuiltInCategory @@ -40,7 +41,7 @@ def invis_style(doc=revit.doc): # get invisible lines graphics style for gs in DB.FilteredElementCollector(doc).OfClass(DB.GraphicsStyle): # find style using the category Id - if gs.GraphicsStyleCategory.Id.IntegerValue == -2000064: + if get_elementid_value(gs.GraphicsStyleCategory.Id) == -2000064: return gs @@ -504,12 +505,12 @@ def delete_existing_view(view_name, doc=revit.doc): def remove_viewtemplate(vt_id, doc=revit.doc): viewtype = doc.GetElement(vt_id) template_id = viewtype.DefaultTemplateId - if template_id.IntegerValue != -1: + if get_elementid_value(template_id) != -1: if forms.alert( "You are about to remove the View Template" " associated with this View Type. Is that cool with ya?", ok=False, yes=True, no=True, exitscript=True): - viewtype.DefaultTemplateId = DB.ElementId(-1) + viewtype.DefaultTemplateId = DB.ElementId.InvalidElementId def family_and_type_names(elem, doc): @@ -562,7 +563,7 @@ def get_param_value_as_string(p): return p.AsValueString() else: - return p.AsElementId().IntegerValue + return get_elementid_value(p.AsElementId()) elif p_storage_type(p) == "Integer": return p.AsInteger() @@ -641,9 +642,9 @@ def get_document_model_bics(doc=revit.doc): if HOST_APP.is_newer_than(2022): bic = category.BuiltInCategory else: - bic = System.Enum.ToObject(BIC, category.Id.IntegerValue) + bic = System.Enum.ToObject(BIC, get_elementid_value(category.Id)) # print (type(bic), bic) - if category.CategoryType==DB.CategoryType.Model and bic!= DB.BuiltInCategory.INVALID and category.Id.IntegerValue <0: + if category.CategoryType==DB.CategoryType.Model and bic!= DB.BuiltInCategory.INVALID and get_elementid_value(category.Id) <0: built_in_categories.append(bic) return built_in_categories diff --git a/lib/pychilizer/select.py b/lib/pychilizer/select.py index 29e3f15..5f659b4 100644 --- a/lib/pychilizer/select.py +++ b/lib/pychilizer/select.py @@ -1,9 +1,12 @@ from pyrevit import revit, DB, forms +from pyrevit.compat import get_elementid_value_func from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter from Autodesk.Revit import Exceptions import rpw from pychilizer import database +get_elementid_value = get_elementid_value_func() + BIC = DB.BuiltInCategory class CatFilter(ISelectionFilter): @@ -12,7 +15,7 @@ def __init__(self, cat): def AllowElement(self, elem): try: - if elem.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(elem.Category.Id) == int(self.cat): return True else: return False @@ -52,6 +55,6 @@ def preselection_with_filter(cat): pre_selection = [] for id in rpw.revit.uidoc.Selection.GetElementIds(): sel_el = revit.doc.GetElement(id) - if sel_el.Category.Id.IntegerValue == int(cat): + if get_elementid_value(sel_el.Category.Id) == int(cat): pre_selection.append(sel_el) return pre_selection \ No newline at end of file diff --git a/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Grids.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Grids.pushbutton/script.py index f003247..f7c440c 100644 --- a/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Grids.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Grids.pushbutton/script.py @@ -4,6 +4,7 @@ from pyrevit import revit, DB, forms +from pyrevit.compat import get_elementid_value_func from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter import rpw from Autodesk.Revit import Exceptions @@ -14,13 +15,15 @@ uidoc = __revit__.ActiveUIDocument active_view = doc.ActiveView +get_elementid_value = get_elementid_value_func() + # Selection Filter class CustomISelectionFilter(ISelectionFilter): def __init__(self, cat): self.cat = cat def AllowElement(self, e): - if e.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(e.Category.Id) == int(self.cat): return True else: return False diff --git a/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Levels.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Levels.pushbutton/script.py index 4001ca4..2286476 100644 --- a/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Levels.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/dimensions.stack/Dim Levels.pushbutton/script.py @@ -10,19 +10,22 @@ from pyrevit import revit, DB from pyrevit import forms +from pyrevit.compat import get_elementid_value_func from Autodesk.Revit.UI.Selection import * from Autodesk.Revit.DB import XYZ from pyrevit import revit, DB +get_elementid_value = get_elementid_value_func() + # Selection Filter class CustomISelectionFilter(ISelectionFilter): def __init__(self, cat): self.cat = cat def AllowElement(self, e): - if e.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(e.Category.Id) == int(self.cat): return True else: return False diff --git a/pyChilizer.tab/Annotate.panel/edit.stack/Toggle grid bubbles.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/edit.stack/Toggle grid bubbles.pushbutton/script.py index 0640a0a..3a9adab 100644 --- a/pyChilizer.tab/Annotate.panel/edit.stack/Toggle grid bubbles.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/edit.stack/Toggle grid bubbles.pushbutton/script.py @@ -13,6 +13,7 @@ from Autodesk.Revit.UI.Selection import * from pyrevit import revit, DB, UI from pyrevit import forms +from pyrevit.compat import get_elementid_value_func #set the active Revit application and document app = __revit__.Application @@ -22,13 +23,15 @@ sel = revit.get_selection() +get_elementid_value = get_elementid_value_func() + # Selection Filter class CustomISelectionFilter(ISelectionFilter): def __init__(self, cat): self.cat = cat def AllowElement(self, e): - if e.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(e.Category.Id) == int(self.cat): return True else: return False diff --git a/pyChilizer.tab/Annotate.panel/edit.stack/Toggle level bubbles.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/edit.stack/Toggle level bubbles.pushbutton/script.py index d81e691..721e3cc 100644 --- a/pyChilizer.tab/Annotate.panel/edit.stack/Toggle level bubbles.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/edit.stack/Toggle level bubbles.pushbutton/script.py @@ -13,6 +13,7 @@ from pyrevit import revit, DB, UI from pyrevit import forms +from pyrevit.compat import get_elementid_value_func #set the active Revit application and document app = __revit__.Application @@ -22,13 +23,15 @@ sel = revit.get_selection() +get_elementid_value = get_elementid_value_func() + # Selection Filter class CustomISelectionFilter(ISelectionFilter): def __init__(self, cat): self.cat = cat def AllowElement(self, e): - if e.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(e.Category.Id) == int(self.cat): return True else: return False diff --git a/pyChilizer.tab/Annotate.panel/legends.stack/Legend by Excel.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/legends.stack/Legend by Excel.pushbutton/script.py index 8ae6639..59474fe 100644 --- a/pyChilizer.tab/Annotate.panel/legends.stack/Legend by Excel.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/legends.stack/Legend by Excel.pushbutton/script.py @@ -3,6 +3,7 @@ You can chose if you want to use/create the Filled Region types matching the name or use visibility overrides.""" from pyrevit.framework import List from pyrevit import revit, DB, forms, script +from pyrevit.compat import get_elementid_value_func import xlrd from rpw.ui.forms import (FlexForm, Label, ComboBox, Separator, Button, TextBox) from collections import OrderedDict @@ -12,6 +13,7 @@ config = script.get_config() +get_elementid_value = get_elementid_value_func() def translate_rectg_vert(rec, vert_offset): # offset recgtangles with a given vertical offset @@ -53,7 +55,7 @@ def invis_style(doc=revit.doc): # get invisible lines graphics style for gs in DB.FilteredElementCollector(doc).OfClass(DB.GraphicsStyle): # find style using the category Id - if gs.GraphicsStyleCategory.Id.IntegerValue == -2000064: + if get_elementid_value(gs.GraphicsStyleCategory.Id) == -2000064: return gs diff --git a/pyChilizer.tab/Annotate.panel/renumber.stack/Renumber by spline.pushbutton/script.py b/pyChilizer.tab/Annotate.panel/renumber.stack/Renumber by spline.pushbutton/script.py index 536df9d..4c6f709 100644 --- a/pyChilizer.tab/Annotate.panel/renumber.stack/Renumber by spline.pushbutton/script.py +++ b/pyChilizer.tab/Annotate.panel/renumber.stack/Renumber by spline.pushbutton/script.py @@ -8,6 +8,7 @@ from pyrevit import revit, DB, UI, HOST_APP from pyrevit import forms, script +from pyrevit.compat import get_elementid_value_func from rpw.ui.forms import (FlexForm, Label, ComboBox, Separator, Button, TextBox) @@ -17,6 +18,8 @@ uidoc = __revit__.ActiveUIDocument active_view = doc.ActiveView +get_elementid_value = get_elementid_value_func() + # Category Ban List cat_ban_list = [ -2000260, # dimensions @@ -47,7 +50,7 @@ def __init__(self, cat): self.cat = cat def AllowElement(self, e): - if e.Category.Id.IntegerValue == int(self.cat): + if get_elementid_value(e.Category.Id) == int(self.cat): return True else: return False @@ -58,7 +61,7 @@ def AllowReference(ref, point): def GetBICFromCat(_cat): # Convert categoryId to BuiltInCategory https://git.io/J1d6O @Gui Talarico - bic = System.Enum.ToObject(DB.BuiltInCategory, _cat.Id.IntegerValue) + bic = System.Enum.ToObject(DB.BuiltInCategory, get_elementid_value(_cat.Id)) return bic def GetInstanceParameters(_cat): @@ -91,7 +94,7 @@ def GetInstanceParameters(_cat): # {key: value for value in list} cat_dict1 = {f.Category.Name: f.Category \ for f in [fam for fam in family_instances] \ - if f.Category.Id.IntegerValue not in cat_ban_list \ + if get_elementid_value(f.Category.Id) not in cat_ban_list \ and f.LevelId and f.get_Geometry(DB.Options())} cat_rooms = DB.Category.GetCategory(doc, DB.BuiltInCategory.OST_Rooms) diff --git a/pyChilizer.tab/Families.panel/family1.stack/InPlace to Loadable.pushbutton/script.py b/pyChilizer.tab/Families.panel/family1.stack/InPlace to Loadable.pushbutton/script.py index d35976f..a0f8f61 100644 --- a/pyChilizer.tab/Families.panel/family1.stack/InPlace to Loadable.pushbutton/script.py +++ b/pyChilizer.tab/Families.panel/family1.stack/InPlace to Loadable.pushbutton/script.py @@ -4,6 +4,7 @@ from pyrevit import revit, DB, UI, HOST_APP, forms, script +from pyrevit.compat import get_elementid_value_func import tempfile from pyrevit.revit.db import query from Autodesk.Revit.UI.Selection import ObjectType, ISelectionFilter @@ -12,6 +13,7 @@ from pychilizer import database, geo from os.path import isfile +get_elementid_value = get_elementid_value_func() #todo: update languages @@ -109,7 +111,7 @@ def select_inplace_filter(): new_curve = geometry.CreateTransformed(inverted_transform_by_ref(bb.Min)) curves.append(new_curve) # get the ID of the element's category -el_cat_id = source_element.Category.Id.IntegerValue +el_cat_id = get_elementid_value(source_element.Category.Id) # check the language of the family templates library language = database.get_family_template_language() fam_template_path = None diff --git a/pyChilizer.tab/Inspect.panel/list.stack/List by Design Option.pushbutton/script.py b/pyChilizer.tab/Inspect.panel/list.stack/List by Design Option.pushbutton/script.py index 0770444..489a178 100644 --- a/pyChilizer.tab/Inspect.panel/list.stack/List by Design Option.pushbutton/script.py +++ b/pyChilizer.tab/Inspect.panel/list.stack/List by Design Option.pushbutton/script.py @@ -2,8 +2,10 @@ __doc__ = "List numbers of elements of project's Design Options, broken down by category." from pyrevit import revit, DB, UI, forms +from pyrevit.compat import get_elementid_value_func from collections import defaultdict +get_elementid_value = get_elementid_value_func() def get_elements_by_do(do, doc=revit.doc): # quickly collect element belonging to a Design Option @@ -62,7 +64,7 @@ def get_full_option_name(design_option): for elem in all_in_do: try: cat_name = elem.Category.Name - cat_id = elem.Category.Id.IntegerValue + cat_id = get_elementid_value(elem.Category.Id) if cat_id <0 and cat_id not in cat_ban_list: element_categories[cat_name].append(elem) counter += 1 diff --git a/pyChilizer.tab/Inspect.panel/list.stack/List by Workset.pushbutton/script.py b/pyChilizer.tab/Inspect.panel/list.stack/List by Workset.pushbutton/script.py index 7fad4f6..49d2e01 100644 --- a/pyChilizer.tab/Inspect.panel/list.stack/List by Workset.pushbutton/script.py +++ b/pyChilizer.tab/Inspect.panel/list.stack/List by Workset.pushbutton/script.py @@ -1,6 +1,8 @@ from pyrevit import revit, DB, UI, forms +from pyrevit.compat import get_elementid_value_func from collections import defaultdict +get_elementid_value = get_elementid_value_func() def get_elements_by_workset(w, doc=revit.doc): # quickly collect element belonging to a Workset @@ -50,7 +52,7 @@ def get_elements_by_workset(w, doc=revit.doc): for elem in all_in_w: try: cat_name = elem.Category.Name - cat_id = elem.Category.Id.IntegerValue + cat_id = get_elementid_value(elem.Category.Id) if cat_id <0 and cat_id not in cat_ban_list: element_categories[cat_name].append(elem) counter += 1 diff --git a/pyChilizer.tab/Project.panel/colorizers2.stack/Filters by Value.pushbutton/script.py b/pyChilizer.tab/Project.panel/colorizers2.stack/Filters by Value.pushbutton/script.py index e6112b9..662d138 100644 --- a/pyChilizer.tab/Project.panel/colorizers2.stack/Filters by Value.pushbutton/script.py +++ b/pyChilizer.tab/Project.panel/colorizers2.stack/Filters by Value.pushbutton/script.py @@ -8,6 +8,7 @@ import filterbyvalueconfig from pyrevit.revit.db import query from pyrevit.forms import reactive, WPF_VISIBLE, WPF_COLLAPSED +from pyrevit.compat import get_elementid_value_func from Autodesk.Revit import Exceptions logger = script.get_logger() @@ -18,6 +19,8 @@ overrides_option = filterbyvalueconfig.get_overrides_config() +get_elementid_value = get_elementid_value_func() + # TODO - disabled for now, let's see .. Line 141-ish # OTHER NOTES EPSILON = 0.001 # for parameters with storage type Double @@ -125,7 +128,7 @@ def add_param_value(param, param_storage_type, values): for id in filterable_parameter_ids: # the Id of BuiltInParameters is a negative one - if id.IntegerValue < 0: + if get_elementid_value(id) < 0: # iterate through all parameters of an element of category(ies) # until the Id of the parameter matches the id from the list of filterable parameters bip = match_bip_by_id(chosen_bics, id) diff --git a/pyChilizer.tab/Select.panel/select.stack/Pick Plan Regions.pushbutton/script.py b/pyChilizer.tab/Select.panel/select.stack/Pick Plan Regions.pushbutton/script.py index 387dd64..94bdbb4 100644 --- a/pyChilizer.tab/Select.panel/select.stack/Pick Plan Regions.pushbutton/script.py +++ b/pyChilizer.tab/Select.panel/select.stack/Pick Plan Regions.pushbutton/script.py @@ -1,4 +1,7 @@ from pyrevit import revit, DB, forms +from pyrevit.compat import get_elementid_value_func + +get_elementid_value = get_elementid_value_func() # todo: to add multi view option @@ -10,7 +13,7 @@ plan_region_ids = [] if all_plan_regions: for pr in all_plan_regions: - if pr.OwnerViewId.IntegerValue == revit.active_view.Id.IntegerValue: + if get_elementid_value(pr.OwnerViewId) == get_elementid_value(revit.active_view.Id): plan_region_ids.append(pr.Id) diff --git a/pyChilizer.tab/Template.panel/template2.stack/List Walls.pushbutton/walltypesconfig.py b/pyChilizer.tab/Template.panel/template2.stack/List Walls.pushbutton/walltypesconfig.py index c94c5b6..c260fc1 100644 --- a/pyChilizer.tab/Template.panel/template2.stack/List Walls.pushbutton/walltypesconfig.py +++ b/pyChilizer.tab/Template.panel/template2.stack/List Walls.pushbutton/walltypesconfig.py @@ -2,6 +2,7 @@ from pyrevit import script, forms, revit, DB +from pyrevit.compat import get_elementid_value_func from rpw.ui.forms import (FlexForm, Label, ComboBox, CheckBox, TextBox, Separator, Button) from pychilizer import units, database from Autodesk.Revit import Exceptions @@ -11,13 +12,15 @@ doc = revit.doc +get_elementid_value = get_elementid_value_func() + my_config = script.get_config() DEFAULT_LENGTH = 5 def get_text_types(doc): text_types = DB.FilteredElementCollector( doc).OfClass(DB.TextNoteType).ToElements() - dict_text_types = {database.get_name(i): i.Id.IntegerValue for i in text_types} + dict_text_types = {database.get_name(i): get_elementid_value(i.Id) for i in text_types} return dict_text_types diff --git a/pyChilizer.tab/Worksets.panel/Workset3D.pushbutton/script.py b/pyChilizer.tab/Worksets.panel/Workset3D.pushbutton/script.py index f38b3c5..cbbc1eb 100644 --- a/pyChilizer.tab/Worksets.panel/Workset3D.pushbutton/script.py +++ b/pyChilizer.tab/Worksets.panel/Workset3D.pushbutton/script.py @@ -11,8 +11,7 @@ from pyrevit import revit, DB from pyrevit import forms - -from pyrevit import revit, DB, forms +from pyrevit.compat import get_elementid_value_func # set the active Revit application and document app = __revit__.Application @@ -20,6 +19,8 @@ uidoc = __revit__.ActiveUIDocument active_view = doc.ActiveView +get_elementid_value = get_elementid_value_func() + # Find us a 3D View to create def FindViewType(_doc): @@ -43,11 +44,11 @@ def SetWorksetVisibility(view, workset): def RemoveViewTemplate(viewtype_id): view_type = doc.GetElement(viewtype_id) template_id = view_type.DefaultTemplateId - if template_id.IntegerValue != -1: + if get_elementid_value(template_id) != -1: if forms.alert("You are about to remove the View Template associated with this View Type. Is that cool with ya?", ok=False, yes=True, no=True, exitscript=True): with revit.Transaction("Remove View Template"): - view_type.DefaultTemplateId = DB.ElementId(-1) + view_type.DefaultTemplateId = DB.ElementId.InvalidElementId # Delete existing views based on workset naming