Skip to content

Commit 7bf00ec

Browse files
authored
Update powerbiCatToM.py
use the following code to collect most categories, some categories still need to be added manualy ``` modelCats = [] for cat in doc.Settings.Categories : if cat.CategoryType == CategoryType.Model and cat.CanAddSubcategory: modelCats.append(cat.Name) ```
1 parent 583a1da commit 7bf00ec

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

workflow/powerbiCatToM.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,72 @@
2020
# import modules
2121
# ------------------------
2222

23-
# in oder to use the clipboard we need to import this
23+
# refer to the clipboard
2424
import clr
2525
clr.AddReference('System.Windows.Forms')
2626
from System.Windows.Forms import Clipboard
2727

28+
# refer to the document manager
29+
clr.AddReference('RevitServices')
30+
import RevitServices
31+
from RevitServices.Persistence import DocumentManager
32+
doc = DocumentManager.Instance.CurrentDBDocument
33+
34+
# refer to the revit API
35+
clr.AddReference('RevitAPI')
36+
import Autodesk
37+
from Autodesk.Revit.DB import *
38+
2839
# ------------------------
2940
# inputs & variables
3041
# ------------------------
3142

43+
# some categoreies exported from navisworks are not included as
44+
# categories in visibility graphics, for examplevv
45+
# Handrails, Landings, Pads, Runs, Slab Edges, Top Rails, Wall Sweeps
46+
3247
# remove single and double spaces after commas and split into list
3348
catsInput = IN[0]
3449
catsReplace1 = catsInput.replace(', ', ',')
3550
catsReplace2 = catsReplace1.replace(', ', ',')
36-
cats = catsReplace2.split(',')
37-
cats.sort()
51+
catsManual = catsReplace2.split(',')
52+
catsManual.sort()
3853

3954
# provide reference strings
4055
hashtag = 'Renamed Columns1'
4156
pathlink = 'pathlink'
4257
filterIn = 'filter_in'
4358
filterOut = 'filter_out'
4459

60+
# ------------------------
61+
# get categories
62+
# ------------------------
63+
64+
# get categories that can add sub categories
65+
# ie the categories which appear in vis graphics
66+
# annotated from forum post with kudos to René Picazo
67+
# https://forum.dynamobim.com/t/get-all-elements-in-model-categories/9447/7
68+
modelCats = []
69+
for cat in doc.Settings.Categories :
70+
if cat.CategoryType == CategoryType.Model and cat.CanAddSubcategory:
71+
modelCats.append(cat.Name)
72+
73+
# only append extra categories if they have been defined in input
74+
if catsInput :
75+
for cat in catsManual :
76+
modelCats.append(cat)
77+
78+
# sort alphabetically so its easier to read
79+
cats = sorted(modelCats)
80+
4581
# ------------------------
4682
# strings
4783
# ------------------------
4884

4985
# the 1st line adds a column to the table based on a filter on the hash
5086
table = ''.join(('= Table.AddColumn(#"', hashtag, '", "filter",'))
5187

88+
# define strings to be used in M code
5289
each = 'each if ['
5390
elif0 = 'else if ['
5491
elif1 = '] = "'

0 commit comments

Comments
 (0)