|
20 | 20 | # import modules |
21 | 21 | # ------------------------ |
22 | 22 |
|
23 | | -# in oder to use the clipboard we need to import this |
| 23 | +# refer to the clipboard |
24 | 24 | import clr |
25 | 25 | clr.AddReference('System.Windows.Forms') |
26 | 26 | from System.Windows.Forms import Clipboard |
27 | 27 |
|
| 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 | + |
28 | 39 | # ------------------------ |
29 | 40 | # inputs & variables |
30 | 41 | # ------------------------ |
31 | 42 |
|
| 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 | + |
32 | 47 | # remove single and double spaces after commas and split into list |
33 | 48 | catsInput = IN[0] |
34 | 49 | catsReplace1 = catsInput.replace(', ', ',') |
35 | 50 | catsReplace2 = catsReplace1.replace(', ', ',') |
36 | | -cats = catsReplace2.split(',') |
37 | | -cats.sort() |
| 51 | +catsManual = catsReplace2.split(',') |
| 52 | +catsManual.sort() |
38 | 53 |
|
39 | 54 | # provide reference strings |
40 | 55 | hashtag = 'Renamed Columns1' |
41 | 56 | pathlink = 'pathlink' |
42 | 57 | filterIn = 'filter_in' |
43 | 58 | filterOut = 'filter_out' |
44 | 59 |
|
| 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 | + |
45 | 81 | # ------------------------ |
46 | 82 | # strings |
47 | 83 | # ------------------------ |
48 | 84 |
|
49 | 85 | # the 1st line adds a column to the table based on a filter on the hash |
50 | 86 | table = ''.join(('= Table.AddColumn(#"', hashtag, '", "filter",')) |
51 | 87 |
|
| 88 | +# define strings to be used in M code |
52 | 89 | each = 'each if [' |
53 | 90 | elif0 = 'else if [' |
54 | 91 | elif1 = '] = "' |
|
0 commit comments