Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/pychilizer/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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
from Autodesk.Revit import Exceptions
import clr
import System


get_elementid_value = get_elementid_value_func()

BIC = DB.BuiltInCategory

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/pychilizer/select.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,6 +13,7 @@
from pychilizer import database, geo
from os.path import isfile

get_elementid_value = get_elementid_value_func()

#todo: update languages

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
Loading