Repository navigation
Expand file tree
/
Copy pathstartup.py
More file actions
141 lines (134 loc) · 5.53 KB
/
Copy pathstartup.py
File metadata and controls
141 lines (134 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# script that is run when Revit starts in the IExternalApplication.Startup event.
try:
# add your code here
from RevitPythonShell.RpsRuntime import ExternalCommandAssemblyBuilder
from Autodesk.Revit.UI import *
import os, clr
clr.AddReference('PresentationCore')
from System.Windows.Media.Imaging import BitmapImage
from System import Uri
#insert path to scripts in next line
appdata = os.getenv('APPDATA')
hvac_scripts = 'RevitPythonShell\\hvac_scripts\\'
path_to_scripts = os.path.join(appdata, hvac_scripts)
if not os.path.exists(path_to_scripts):
path_to_scripts = os.path.join('C:\\Users\\igor\\gdrive\\Code\\revit_scripts')
scripts = {
'PrintPDF':
{
'folder': os.path.join(path_to_scripts, 'PrintPDF'),
'name': r"print_sheets.py",
'dll': r"RPS_print_sheets.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'print sheets',
'pb_name': 'pb_PrintPDF'
},
'AddParameters':
{
'folder': os.path.join(path_to_scripts, 'AddParameters'),
'name': r"add_parameters.py",
'dll': r"RPS_add_parameters.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'add parameters',
'pb_name': 'pb_AddParameters'
},
'UnloadFamilies':
{
'folder': os.path.join(path_to_scripts, 'UnloadUploadFamilies'),
'name': r"unload_families.py",
'dll': r"RPS_unload_families.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'unload families',
'pb_name': 'pb_unload families'
},
'NumerateHoles':
{
'folder': os.path.join(path_to_scripts, 'NumerateHoles'),
'name': r"pyNumerateHoles.py",
'dll': r"RPS_numerate_holes.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'numerate holes',
'pb_name': 'pb_numerate holes'
},
'SelectView':
{
'folder': os.path.join(path_to_scripts, 'SelectView'),
'name': r"select_view.py",
'dll': r"RPSAddin_select_view.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'select view',
'pb_name': 'pb_select view'
},
'ExportSchedules':
{
'folder': os.path.join(path_to_scripts, 'ExportSchedules'),
'name': r"export_specification.py",
'dll': r"RPSAddin_export_specification.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'export schedules',
'pb_name': 'pb_export schedules'
},
# 'HeatLossCalc':
# {
# 'folder': os.path.join(path_to_scripts, 'HeatLossCalc'),
# 'name': r"app.py",
# 'dll': r"RPSAddin_heatloss_calc.dll",
# 'large_img': r"PythonScript32x32.png",
# 'small_img': r"PythonScript16x16.png",
# 'description': 'heat loss calc',
# 'pb_name': 'pb_heat loss calc'
# },
'ViewCreator':
{
'folder': os.path.join(path_to_scripts, 'ViewCreator'),
'name': r"app.py",
'dll': r"RPSAddin_view_creator.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'create views',
'pb_name': 'pb_create views'
},
'TestScript':
{
'folder': os.path.join(path_to_scripts, 'TestScript'),
'name': r"app.py",
'dll': r"RPSAddin_test_script.dll",
'large_img': r"PythonScript32x32.png",
'small_img': r"PythonScript16x16.png",
'description': 'for testing',
'pb_name': 'pb_test_script'
},
# 'UploadFamilies':
# {
# 'folder': r"C:\\Users\\igor\\Google Диск\\Code\\pyUnloadUploadFamilies",
# 'name': r"upload_families.py",
# 'dll': r"RPS_upload_families.dll",
# 'large_img': r"PythonScript32x32.png",
# 'small_img': r"PythonScript16x16.png",
# 'description': 'upload families',
# 'pb_name': 'pb_upload families'
# },
}
panel = __uiControlledApplication__.CreateRibbonPanel('pyHVAC')
for script, settings in scripts.items():
PROJECT_FOLDER = settings['folder']
SCRIPT_PATH = os.path.join(PROJECT_FOLDER, settings['name'])
DLL_PATH = os.path.join(PROJECT_FOLDER, settings['dll'])
LARGE_IMG = os.path.join(PROJECT_FOLDER, settings['large_img'])
SMALL_IMG = os.path.join(PROJECT_FOLDER, settings['small_img'])
builder = ExternalCommandAssemblyBuilder()
builder.BuildExternalCommandAssembly(DLL_PATH, {script: SCRIPT_PATH})
pdb = PushButtonData(settings['pb_name'], settings['description'], DLL_PATH, script)
pdb.Image = BitmapImage(Uri(SMALL_IMG))
pdb.LargeImage = BitmapImage(Uri(LARGE_IMG))
panel.AddItem(pdb)
__window__.Close() # closes the window
except:
import traceback # note: add a python27 library to your search path first!
traceback.print_exc() # helps you debug when things go wrong