Creating Document Groups¶
Creating Document Groups¶
1ot = impact.gui.output_toolbox
2db = impact.active_database
3
4docs = db.documents
5
6
7def create_or_update_group(name, def_extensions, allow_all_extensions):
8 group = groups.item(name)
9
10 if group.isNone():
11 group = groups.add(name)
12
13 if not group.isNone():
14 group.default_extensions = def_extensions
15 group.allow_all_extensions = allow_all_extensions
16 group.do_update()
17
18 ot.add("Successfully created or updated Group '" + str(name) + "'")
19
20 else:
21 ot.add("Failed to create or update Group '" + str(name) + "'")
22
23
24ot.clear()
25
26docs = db.documents
27
28if docs is None:
29 ot.add("No document support in the database")
30else:
31 ot.add("Document support is enabled in this database")
32
33 settings = db.settings.document_settings
34
35 groups = settings.groups
36
37 ot.add("Document Groups (Before): " + str(groups.count))
38
39 create_or_update_group("CAD Documents", "ipd;dwg;dxf", True)
40 create_or_update_group("Graphics Files", "jpg;jpeg;png;bmp;ai;pdf", True)
41
42 ot.add("Document Groups (After): " + str(groups.count))