-
Notifications
You must be signed in to change notification settings - Fork 1
/
WHA Revit Launcher.ahk
2806 lines (2397 loc) · 71.9 KB
/
WHA Revit Launcher.ahk
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Persistent
#SingleInstance, Force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Include ..\Class_CtlColors\Sources\Class_CtlColors.ahk
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; ©2014 Wright Heerema | Architects
; Created by Michael Pfammatter
; This utility will launch a Revit file for you using the appropriate version of the software as well as
; automate a few things you don't want to be doing over and over and over again.
; ### Set Variables ###
SetTitleMatchMode, RegEx ;Allows for less precise window finding
; Set the name of the program. This should be the same as the named exe file
; I don't grab this using A_ variables in case a user changes the filename
If A_IsCompiled
{
programName = WHA Revit Launcher
FileGetVersion, scriptVersion, %A_ScriptFullPath%\
devDisplay := false
}
Else
{
programName = Revit Launcher Dev
scriptVersion = LaunchDev
devDisplay := true
}
; Location where icons and images are kept
supportFolder = %A_ScriptDir%\Support
; Name of the bimGuy. I'm trying to keep it generic but this may need to
; change in the future
bimGuy = your BIM Coordinator
; Global variable need to be set later in a function
mouseX =
mouseY =
; Allow for some color consistency in menus
guiColor1 = 666666
guiColor2 = 9f1d21
guiColor3 = ffffff
; Set the path of the file with local settings".
; If a user ini file doesn't exist, create one.
iniPathLocal = %A_AppData%\%programName%\%programName%.ini
IfNotExist %iniPathLocal%
{
IfNotExist %A_AppData%\%programName%
FileCreateDir, %A_AppData%\%programName%
FileCopy, %A_ScriptDir%\%programName%.ini, %iniPathLocal%
If ErrorLevel ; If copying the file goes wrong, notify and exit
{
PrettyMsg("We were unable to properly initialize " . programName . ". Please see " . bimGuy . " for additional information.", "exit")
LogMe("Program", "Startup", "FAIL", "settings ini file copy", iniPathLocal)
}
; As long as we are setting things up, make sure the program starts when the user logs including
; This can be turned off in settings
linkFile = %A_Startup%\%programName%.lnk
IfNotExist %LinkFile%
FileCreateShortcut, %A_ScriptFullPath%, %LinkFile%
}
;load up the local settings and favorites
iniLocal := class_EasyIni(iniPathLocal)
If (!iniLocal.Settings.iniPathCentral) ;Check if settings file is good
{
LogMe("Program", "Startup", "Fail", "iniPathLocal file not found", iniPathLocal)
PrettyMsg("There is a problem with your installation of " . programName . ". Please see " . bimGuy . " for addtional information. This program will now exit", "exit")
}
; Create a log to keep track of comings and goings
; logCheck := 1
If (iniLocal.Settings.LocalLog) ;Check if ini file has log setting
{
localLog := iniLocal.Settings.LocalLog
}
Else ;add a setting with the default value
{
SplitPath, iniPathLocal,, settingsFolder
localLog := settingsFolder . "\Log"
iniLocal.AddKey("Settings", "LocalLog", localLog)
iniLocal.save()
}
; Load up the global project list
iniPathCentral := iniLocal.Settings.iniPathCentral
IfNotExist, %iniPathCentral% ;If the path the the central ini doesn't resolve check a few things
{
LogMe("Program", "Startup", "Fail", "Valid Central INI file not found")
iniPathProgram := A_ScriptDir . "\" . programName ".ini"
IfNotExist, %iniPathProgram%
{
LogMe("Program", "Startup", "Fail", "Program Files ini missing")
PrettyMsg("There is a problem with your installation of " . programName . ". Please see " . bimGuy . " for addtional information. This program will now exit", "exit")
}
iniProgram := class_EasyIni(iniPathProgram)
iniPathCentral := iniProgram.Settings.iniPathCentral
IfExist, %iniPathCentral%
{
LogMe("Program", "Startup", "Fail", "Attempting to overwrite local central location")
iniLocal.Settings.iniPathCentral := iniPathCentral
iniLocal.save()
LogMe("Program", "Startup", "Success", "Overwrote local central location to " . iniLocal.Settings.iniPathCentral)
}
}
else
{
iniCentral := class_EasyIni(iniPathCentral)
}
; Get some default settings
detach := iniLocal.Settings.Detach
workset := iniLocal.Settings.Workset
debug := iniLocal.Settings.Debug
audit := true
; Set location where local files will be saved
If (iniLocal.Settings.LocalFolder) ;Check if ini file has setting
{
localFolder := iniLocal.Settings.LocalFolder
}
Else ;add a setting with the default value to the ini file
{
localFolder = %A_MyDocuments%\Revit
iniLocal.AddKey("Settings", "LocalFolder", localFolder)
iniLocal.save()
}
; Set whether an explorer window will be opened to the project folder
If (iniLocal.Settings.ExploreDefault) ;Check if ini file has setting
{
exploreLaunch := iniLocal.Settings.ExploreDefault
}
Else ;add a setting with the default value to the ini file
{
exploreLaunch := 0
iniLocal.AddKey("Settings", "ExploreDefault", exploreLaunch)
iniLocal.save()
}
; Debug function to make finding problems easier
DebugMe("Start")
; By default we assume Revit is not running
revitRunning := 0
IfNotExist, %localLog%
FileCreateDir, %localLog%
If (iniLocal.Settings.ExitReason) ;Check if ini file has setting
{
lastExit := iniLocal.Settings.ExitReason
}
Else ;add a setting with the default value to the ini file
{
iniLocal.AddKey("Settings", "ExitReason", "Initial")
iniLocal.save()
}
logMe("Program", "Opened", lastExit)
; Check if user can write to the global list of projects "iniPathCentral"
SplitPath, iniPathCentral, , iniCentralDir, , iniCentralName
globalLog = %iniCentralDir%\%iniCentralName%.log
If !LogMe("ManageList", "Write check")
{
iniCentralEdit := 0
LogMe("Program", "Write check", "Fail")
}
Else
{
iniCentralEdit := 1
LogMe("Program", "Write check", "Success")
}
noNetwork := 0
networkLogged := 0
SetTimer, NetworkCheck, 5000
GoSub, NetworkCheck
if !noNetwork
GoSub, TrayMenu
OnExit, ExitSub
; This is all that is done when the program is started
; Any additional features will need to be initialized by the user
Return
; Check if the network is available
NetworkCheck:
IfNotExist, %iniPathCentral%
{
noNetwork := 1
if !networkLogged
{
networkLogged := LogMe("Program", "Network Check", "Fail")
ReloadMe("noshow")
}
}
IfExist, %iniPathCentral%
{
if noNetwork
{
;need to reload the central ini in case the program launched first time without network
iniCentral := class_EasyIni(iniPathCentral)
noNetwork := !logMe("Program", "Network Check", "Success")
ReloadMe("noshow")
}
noNetwork := 0
return
return
}
return
; ### End of Set Variables ###
; ### Create the right click menu ###
TrayMenu:
; Read list of favorites
audit := false
favList := iniLocal.GetSections(, "C")
Loop, Parse, favList, `n
{
if A_Index = 1
favList := ""
if InStr(A_LoopField, "Favorite")
if favList
favList := favList . "`n" . A_LoopField
else
favList := A_LoopField
}
; Turn favList into an array
StringSplit, favList, favList, `n
; Set a variable to count the number of favorites a user has
favN := 0
; Go through a users ini file and set variables for all the favorites
Loop, %favList0%
{
favSection := favList%A_Index%
{
favN += 1
; Assign the project ID from the local ini file
fav%favN% := iniLocal [favSection].ProjectID
; Assign the project name from the local ini file
fav%favN%Name := iniLocal [favSection].Name
}
}
;Populate right click menu including favorites
Menu, tray, NoStandard ;Get rid of default menu items
Menu, tray, Icon, %supportFolder%\wha.ico
Menu, tray, Tip, Wright Heerema | Architects`nRevit Launcher
;Give different menu options if the S drive is not available
If noNetwork
{
Menu, tray, Add, Error! Central Project List Not Found, TrayReset
Menu, tray, Icon, Error! Central Project List Not Found, %supportFolder%\alert.ico
}
Else
{
Menu, tray, Add, Find Project and Launch, FindLaunch
Menu, tray, icon, Find Project and Launch, %supportFolder%\search.ico
Menu, tray, Add
Menu, tray, Add, Quick Launch Add/Remove, AddRemove
Menu, tray, icon, Quick Launch Add/Remove, %supportFolder%\star.ico
Loop, % FavN ;search through list of favorites and make menu items for them
{
; Get the current project version from the Global Project List
favVersion%A_Index% := iniCentral [fav%A_Index%].Version
; Check if project still exists
if !(favVersion%A_Index%) and !noNetwork
{
PrettyMsg("Uh oh, The project:`n`n" . fav%A_Index%Name . "`n`ncould not be found in the Global Project List. You may want to remove it from your favorites. Please see " . bimGuy . " should this problem persist.")
;~ iniLocal.DeleteSection(favList%A_Index%)
;~ iniLocal.Save()
LogMe("Favorite", "Remove", favList%A_Index%, "No longer in global list")
}
else
{
favTitle := fav%A_Index%Name
favIcon := favVersion%A_Index%
Menu, tray, Add, %favTitle%, favSub
IfExist, %supportFolder%\Revit%favIcon%file.ico
Menu, tray, Icon, %favTitle%, %supportFolder%\Revit%favIcon%file.ico, 1, 16
If detach
Menu, tray, Icon, %favTitle%, %supportFolder%\detach%favIcon%.ico, 1, 16
}
}
}
Menu, tray, Add
Menu, tray, Add, Detach Models, DetachSub
If detach
Menu, tray, Check, Detach Models
Menu, tray, Add, Specify Worksets, WorksetSub
If workset
Menu, tray, Check, Specify Worksets
Menu, tray, Add
Menu, tray, Add, Settings, SettingsSub
if !noNetwork
{
Menu, Utilities, Add, New Project Structure Setup, ProjStructSub
Menu, Utilities, Add, Manage Global Project List, ManageListSub
Menu, Utilities, Add, Audit a Central Model, AuditSub
Menu, tray, Add, Utilities, :Utilities
}
Menu, tray, Icon, Settings, %supportFolder%\settings.ico
Menu, tray, Add, %programName% Help, HelpSub
If !A_IsCompiled
{
Menu, Utilities, Add
Menu, Utilities, Add, ListVars, ListVarsSub
Menu, Utilities, Add, KeyHistory, KeyHistorySub
Menu, Utilities, Add, Built in variables, BuiltInVar
Menu, Utilities, Add, Debug View, debugCheck
If devDisplay
Menu, Utilities, Check, Debug View
}
Menu, tray, Add, Exit, TrayExit
OnMessage(0x404, "AHK_NOTIFYICON") ;Allow left-click of tray icon
If !iniCentralEdit and !noNetwork
{
Menu, Utilities, Disable, Manage Global Project List
Menu, Utilities, Disable, Audit a Central Model
}
;~ gosub, AuditSub ; for debug purposes, please remove when complete
return
; What to do if the tray icon is left-clicked
RightShow:
Menu, tray, Show
Return
; Assign project variables and run the main routine
FavSub:
menuID := A_ThisMenuItemPos - 3
projectID := fav%menuID%
GoSub, MainRoutine
return
; If the server is not available, check again when the user requests
TrayReset:
PrettyMsg("The centralized list of projects could not be found.`nThis may be due to the network not being available. Please check the network and try again. Consult " . bimGuy . " should this problem persist.")
ReloadMe()
LogMe("MenuTray", "No Network")
return
; Swap out the icons and prepare to launch all models detached
DetachSub:
detach := MenuCheck(detach, "Detach Models")
; iniLocal.Settings.Detach := detach
; iniLocal.Save()
ReloadMe()
return
; Prepare to launch all models with the "Specify Worksets" dialog box in Revit
WorksetSub:
workset := MenuCheck(workset, "Specify Worksets")
; iniLocal.Settings.Workset := workset
; iniLocal.Save()
ReloadMe()
return
ListVarsSub:
ListVars
return
KeyHistorySub:
KeyHistory
return
BuiltInVar:
PrettyMsg("A_ScriptDir: " . A_ScriptDir . "`n`nA_IsCompiled: " . A_IsCompiled . "`n`nA_MyDocuments: " . A_MyDocuments)
return
DebugCheck:
devDisplay := !devDisplay
ReloadMe()
return
ProjStructSub:
if A_IsCompiled
Run, New Project Structure Setup.exe
else
Run, %programfiles%\Autohotkey\Autohotkey.exe "%A_WorkingDir%\New Project Structure Setup.ahk"
return
TrayExit:
ExitApp
ExitSub: ;Leaving so soon?
iniLocal := class_EasyIni(iniPathLocal)
iniLocal.Settings.ExitReason := A_ExitReason
iniLocal.Save()
LogMe("Program", "Closed", A_ExitReason)
ExitApp
return
; ### End of right click menu ###
UserListView:
loop, %centralSections0%
{
LV_Add(,iniCentral [centralSections%A_Index%].Number, iniCentral [centralSections%A_Index%].Name, iniCentral [centralSections%A_Index%].Version, centralSections%A_Index%)
}
;Set column widths and hide the LaunchID column
LV_ModifyCol(1, "SortDesc")
LV_ModifyCol(1, 95)
LV_ModifyCol(2, 335)
LV_ModifyCol(3, 47)
LV_ModifyCol(4, 0)
;Sort by the first column
Return
; ### Create the Search and Launch Menu ###
; Menu that is launched when a user wants to open a project they don't access frequently.
FindLaunch:
; Load up the global project list
guiWidth := 500
guiMargin := 30
guiWidthTotal := guiWidth + (guiMargin * 2)
iniCentral := class_EasyIni(iniPathCentral)
iniLocal := class_EasyIni(iniPathLocal)
; Get all of the projects
centralSections := iniCentral.GetSections(,"C")
; Turn list of projects into an array for looping
StringSplit, centralSections, centralSections, `n
; Create the actual menu
Gui, FindLaunch:New,, %programName%
Gui, FindLaunch:Font, s24 , Arial
Gui, FindLaunch:Add, Text, center w%guiWidth%, Select a project to Launch:
Gui, FindLaunch:Font, s10 , Arial
Gui, FindLaunch:Add, ListView, AltSubmit r10 w%guiWidth% gFindLaunchList -Multi, Number|Name|Version|LaunchID
; Add projects to the listview
GoSub, UserListView
Gui, FindLaunch:Font, s10 c%guiColor1%, Arial
Gui, FindLaunch:Add, Text, w%guiWidth% center yp+240, Choose a project. A local file will be created and opened using the correct version of Revit. Choosing detach will open the project disconnected from the central file.`nDon't see your project listed? Contact %bimGuy%.
Gui, FindLaunch:Font, s18 cBlack, Arial
; Change the button to reflect if we are opening detached or specifed worksets
Gui, FindLaunch:Add, Button, w150 yp+60 xp+10 gFindLaunchFind, &Launch
Gui, FindLaunch:Add, Button, w150 yp+0 xp+165 gFindLaunchDetach, &Detach
Gui, FindLaunch:Add, Button, wp yp+0 xp+165 Default gFindLaunchGuiClose, &Cancel
Gui, FindLaunch:Font, s12 cWhite, Arial
Gui, FindLaunch:Add, Text, w%guiWidthTotal% h70 x0 hwndrStripe cYellow,
Gui, FindLaunch:Add, CheckBox, xm+84 yp+8 vaddQuickCheck hwndrCheck, %A_Space%%A_Space%Also add project to my "Quick Launch" Menu
GuiControl, FindLaunch:Disable, Button1
GuiControl, FindLaunch:Disable, Button2
GuiControl, FindLaunch:Hide, addQuickCheck
Gui, FindLaunch:Show, w%guiWidthTotal% h440
CtlColors.Attach(rStripe, "", "Yellow")
CtlColors.Attach(rCheck, "", "White")
Return
; Enable the launch button once the user selects a project
FindLaunchList:
If A_GuiEvent = I
{
If !detach
GuiControl, FindLaunch:Enable, Button1
GuiControl, FindLaunch:Enable, Button2
RowNumber := 0
RowNumber := LV_GetNext(RowNumber)
LV_GetText(rowText, rowNumber, 4)
if !iniLocal["favorite" . rowText]
{
GuiControl, FindLaunch:Show, addQuickCheck
Gui, FindLaunch:Show, w560 h473
CtlColors.Change(rStripe, guiColor2)
CtlColors.Change(rCheck, guiColor2, "White")
}
else
{
GuiControl, FindLaunch:Hide, addQuickCheck
Gui, FindLaunch:Show, w560 h440
CtlColors.Change(rStripe, "")
CtlColors.Change(rCheck, "", "White")
}
}
If A_GuiEvent = DoubleClick
if detach
GoSub, FindLaunchDetach
else
GoSub, FindLaunchFind
Return
FindLaunchDetach:
detach := 1
; Get the project selected, set project variables, and run the main routine
FindLaunchFind:
RowNumber := 0
RowNumber := LV_GetNext(RowNumber)
LV_GetText(rowText, rowNumber, 4)
projectID := rowText
Gui, FindLaunch:Submit
GuiControlGet, addQuickCheck
if addQuickCheck
{
addQuick := !iniLocal["favorite" . rowText] ? projectID : false
}
addQuickCheck := 0
DebugMe("FindLaunchFind")
LogMe("FindLaunch", projectID)
Gui, FindLaunch:Destroy
GoSub, MainRoutine
Return
; ### End of the Search and Launch Menu ###
; ### Create the Add/Remove Quick Launch Menu ###
; Menu that allows users to add or remove programs they frequent to the tray menu
; First we simply ask if they want to add to the list or remove from the list
AddRemove:
guiTitle := "What would you like to do?"
guiWidth := 550
bWidth := (guiWidth - 10) / 2
bLoc := bWidth + 10
tFont := GetFontMax(guiTitle, guiWidth)
Gui, AddRemove:New,, %programName%
Gui, AddRemove:Font, %tFont%, Arial
Gui, AddRemove:Add, Text, center w%guiWidth%, %guiTitle%
Gui, AddRemove:Font, s18, Arial
Gui, AddRemove:Add, Button, Default w%bWidth% gAddProject, &Add a Project
Gui, AddRemove:Add, Button, wp xp+%bLoc% gRemoveProject, &Remove a Project
Gui, AddRemove:Show
return
; Menu to add a project to the quick launch list
AddProject:
; Load up the global list of projects
iniCentral := class_EasyIni(iniPathCentral)
; Get all of the projects in the list
centralSections := iniCentral.GetSections(,"C")
; Create an array of the projects for looping
StringSplit, centralSections, centralSections, `n
; Create the add project menu
guiTitle := "Add a project to your Quick Launch Menu:"
guiWidth := 500
bWidth := (guiWidth - 10) / 2
bLoc := bWidth + 10
tFont := GetFontMax(guiTitle, guiWidth)
Gui, AddProject:New,, %programName%
Gui, AddProject:Font, %tFont% , Arial
Gui, AddProject:Add, Text, center w%guiWidth%, %guiTitle%
Gui, AddProject:Font, s10 , Arial
Gui, AddProject:Add, ListView, AltSubmit r10 w500 gAddProjectList -Multi, Number|Name|Version|LaunchID
; Add all of the projects to the listview
GoSub, UserListView
Gui, AddProject:Font, s10 c%guiColor1%, Arial
Gui, AddProject:Add, Text, w500 center yp+230, Choose a project and it will be added to your "Quick Launch" menu.`nDon't see your project listed? Contact %bimGuy%.
Gui, AddProject:Font, s18 cBlack, Arial
Gui, AddProject:Add, Button, w%bWidth% yp+60 xm gAddProjectAdd, &Add to list
Gui, AddProject:Add, Button, wp xp+%bLoc% Default gAddProjectGuiClose, &Cancel
GuiControl, Disable, &Add to list
Gui, AddProject:Show
; Destroy the menu that asks if we want to add or remove
Gui, AddRemove:Destroy
return
; Menu to remove a program from the Quick Launch list
RemoveProject:
; Create the Remove from Quick Launch menu
guiTitle := "Select a project to remove:"
guiWidth := 500
bWidth := (guiWidth - 10) / 2
bLoc := bWidth + 10
tFont := GetFontMax(guiTitle, guiWidth)
Gui, RemoveProject:New,, %programName%
Gui, RemoveProject:Font, %tFont% , Arial
Gui, RemoveProject:Add, Text, center w%guiWidth%, %guiTitle%
Gui, RemoveProject:Font, s10, Arial
Gui, RemoveProject:Add, ListView, AltSubmit r10 w%guiWidth% gRemoveProjectList, Name|ID
; Add a list of all the projects in the Quick Launch list to the list view
loop, %favList0%
{
LV_Add(,iniLocal [favList%A_Index%].Name, favList%A_Index%)
}
LV_ModifyCol(1, 498)
LV_ModifyCol(2, 0)
Gui, RemoveProject:Font, s10 c%guiColor1%, Arial
Gui, RemoveProject:Add, Text, w500 center yp+230, The selected project will be removed from your "Quick Launch" menu.
Gui, RemoveProject:Font, s18 cBlack, Arial
Gui, RemoveProject:Add, Button, w%bWidth% xm yp+60 gRemoveProjectRemove, &Remove from list
Gui, RemoveProject:Add, Button, w%bWidth% xp+%bLoc% Default gRemoveProjectGuiClose, &Cancel
GuiControl, Disable, &Remove from list
Gui, RemoveProject:Show
; Destroy the menu that asks if we want to add or remove
Gui, AddRemove:Destroy
return
; Exit out of a whole bunch of menus
AddRemoveGuiEscape:
AddRemoveGuiClose:
AddProjectGuiEscape:
AddProjectGuiClose:
RemoveProjectGuiEscape:
RemoveProjectGuiClose:
FindLaunchGuiEscape:
FindLaunchGuiClose:
Gui, Destroy
; Once the menu is destroyed, reopen the tray menu to let users know it is still down there
TrayOpen()
return
RemoveProjectList:
; Enable the remove button once a users selects a project
If A_GuiEvent = I
GuiControl, RemoveProject:Enable, Button1
If A_GuiEvent = DoubleClick
GoSub, RemoveProjectRemove
Return
RemoveProjectRemove:
; This does the hard work of actually REMOVING the project from the Quick Launch list
RowNumber := 0
rowCount := 0
rowNameAll := ""
delRows := Object()
Loop, % LV_GetCount("Selected")
{
rowNumber := LV_GetNext(rowNumber)
LV_GetText(rowName, rowNumber, 1)
LV_GetText(rowText, rowNumber, 2)
delRows[A_Index] := rowText
rowNameAll := if rowNameAll ? rowNameAll . "`n" . rowName : rowName
}
pMessage := PrettyMsg("Are you sure you want to remove the following projects from your list?`n`n" . rowNameAll, "question")
if (pMessage = "Yes")
{
Loop, % delRows.MaxIndex()
{
iniLocal.DeleteSection(delRows[A_Index])
Gui, RemoveProject:Destroy
LogMe("Favorite", "Remove", delRows[A_Index])
}
iniLocal.Save()
ReloadMe()
}
else if (pMessage = "No")
Gui, RemoveProject:Destroy
rowNameAll := ""
delRows := Object()
return
AddProjectList:
; Enable the add button once a user selects a project
If A_GuiEvent = I
GuiControl, AddProject:Enable, Button1
If A_GuiEvent = DoubleClick
GoSub, AddProjectAdd
Return
AddProjectAdd:
; This does the hard work of actually ADDING the project to the Quick Launch list
; Make sure you zero out the RowNumber otherwise you could see some weird behaviour
addRows := Object()
if addQuick
{
rowText := addQuick
}
else
{
RowNumber := 0
RowNumber := LV_GetNext(RowNumber)
LV_GetText(rowText, rowNumber, 4)
}
newFavSection = Favorite%rowText%
newFavNumber := iniCentral [rowText].Number
newFavName := iniCentral [rowText].NameShort
if instr(favList, newFavSection)
{
PrettyMsg(newFavNumber . " " . newFavName . " is already in your list of projects")
}
else
{
iniLocal.AddSection(newFavSection, "ProjectID", rowText)
iniLocal.AddKey(newFavSection, "Name", newFavNumber . " " . newFavName)
iniLocal.AddKey(newFavSection, "Detach", "0")
iniLocal.AddKey(newFavSection, "Workset", "0")
iniLocal.save()
Gui, AddProject:Destroy
LogMe("Favorite", "Add", rowText, newFavNumber, newFavName, "Detach 0", "Workset 0")
ReloadMe()
}
return
; ### End of Add/Remove Quick Launch Menu ###
; ### Create the Settings Menu ###
SettingsSub:
detachDefault := iniLocal.Settings.Detach
worksetDefault := iniLocal.Settings.Workset
exploreDefault := iniLocal.Settings.ExploreDefault
linkFile = %A_Startup%\%programName%.lnk
IfExist %linkFile%
startupExist := 1
Else
startupExist := 0
guiTitle := programName . " Settings:"
guiWidth := 500
bWidth := (guiWidth - 10) / 2
bLoc := bWidth + 10
tFont := GetFontMax(guiTitle, guiWidth)
Gui, Settings:New,, %programName%
Gui, Settings:Font, %tFont% cBlack, Arial
Gui, Settings:Add, Text, center w%guiWidth%, %guiTitle%
;Start of default settings section
Gui, Settings:Font, s12, Arial
Gui, Settings:Add, Text, yp+80 section, Defaults
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Checkbox, xs+100 ys-5 vdetachCheck gSettingsSubDetach, Detach by default
GuiControl,, detachCheck, %detachDefault%
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400, Controls whether "Detach Models" is enabled when you first open %programName%. This option is perfect for Project Managers who only need to query a model. You can temporarily disable it before launching if you need to save changes to a model.
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xp-100 yp+75 section,
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Checkbox, xs+100 ys-5 vworksetCheck gSettingsSubWorkset, Specify worksets by default
GuiControl,, worksetCheck, %worksetDefault%
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400, Controls whether the "Specify Worksets" dialog box is opened by default. Choose this option if you frequently work on larger Revit models.
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xp-100 yp+50 section,
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Checkbox, xs+100 ys-5 vexploreCheck gSettingsSubExplore, Open Project Folder in Explorer
GuiControl,, exploreCheck, %exploreDefault%
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400, With this setting checked, a Windows Explorer window will be opened to the projects working directory when the project is launched.
;Start of behavior at startup section
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xp-100 yp+75 section, Startup
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Checkbox, xs+100 ys-5 vstartupCheck gSettingsSubStartup, Startup on Windows Login
GuiControl,, startupCheck, %startupExist%
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400, If checked, %programName% will open automatically when you log in to Windows. Just set it and forget it. :)
;Start of file locations settings section
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xp-100 yp+75 section, Locations
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Text, xs+100 ys-5, Local File Save Location
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400 vlocalLocation, %localFolder%
Gui, Settings:Add, Button, w75 xs+100 ys+45 gSettingsSubLocal, Change
Gui, Settings:Add, Button, w75 xs+185 ys+45 gSettingsSubLocalDefault, Default
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xm yp+50 section,
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Text, xs+100 ys-5, Log Files
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400 vlogLocation, %localLog%
Gui, Settings:Add, Button, w75 xs+100 ys+45 gSettingsSubLog, View
;Start of about section
Gui, Settings:Font, s12 cBlack, Arial
Gui, Settings:Add, Text, xm yp+75 section, About
Gui, Settings:Font, s18, Arial
Gui, Settings:Add, Text, xs+100 ys-5, %programName%
Gui, Settings:Font, s9 c%guiColor1%, Arial
Gui, Settings:Add, Text, xs+100 ys+25 w400, Version: %scriptVersion%
Gui, Settings:Add, Text, xs+100 yp+18 w400, %programName% was created by Michael Pfammatter and is copyright by Wright Heerema | Architects in 2014
Gui, Settings:Show
DebugMe("SettingsSub")
return
SettingsGuiEscape:
SettingsGuiClose:
ReloadMe()
return
SettingsSubDetach:
iniLocal.Settings.Detach := !detachDefault
iniLocal.Save()
detachDefault := iniLocal.Settings.Detach
GuiControl,, detachCheck, %detachDefault%
detach := detachDefault
LogMe("Settings", "detachDefault", detach)
return
SettingsSubWorkset:
iniLocal.Settings.Workset := !worksetDefault
iniLocal.Save()
worksetDefault := iniLocal.Settings.Workset
GuiControl,, worksetCheck, %worksetDefault%
workset := worksetDefault
LogMe("Settings", "worksetDefault", workset)
return
SettingsSubExplore:
;Allows user to set whether an explorer window will be opened to the project folder after the model is launched.
DebugMe("SettingsSubExplore")
iniLocal.Settings.ExploreDefault := !exploreDefault
iniLocal.Save()
exploreDefault := iniLocal.Settings.ExploreDefault
GuiControl,, exploreCheck, %exploreDefault%
exploreLaunch := exploreDefault
LogMe("Settings", "exploreLaunch", exploreLaunch)
Return
SettingsSubStartup:
DebugMe("Settings Startup Check")
IfNotExist, %LinkFile%
{
FileCreateShortcut, %A_ScriptFullPath%, %LinkFile%
If ErrorLevel
{
PrettyMsg("There was a problem creating a shortcut in your startup folder, " . A_Startup . ". Please contact %bimGuy% for additional information.")
LogMe("Error", "Shortcut", A_ScriptFullPath, LinkFile)
}
}
Else
{
FileDelete, %LinkFile%
If ErrorLevel
{
PrettyMsg("There was a problem removing the startup shortcut from your startup folder, " . A_Startup . ". Please contact %bimGuy% for additional information.")
}
}
IfExist %linkFile%
startupExist := 1
Else
startupExist := 0
GuiControl,, startupCheck, %startupExist%
LogMe("Settings", "startupExist", startupExist)
Return
SettingsSubLocal:
;Allows user to set location where local files will be saved. It also give the option to set it back to the default location.
PrettyMsg("Please make sure to set a folder on your local computer. Revit doesn't handle local files located on network drives well.")
FileSelectFolder, selectedFolder, , 3, Choose a location for your local files to reside:
If ErrorLevel
Return
localFolder := selectedFolder
iniLocal.Settings.LocalFolder := localFolder
iniLocal.save()
GuiControl, , localLocation, %localFolder%
LogMe("Settings", "localLocation", localFolder)
Return
SettingsSubLocalDefault:
IfEqual, localFolder, %A_MyDocuments%\Revit
PrettyMsg("The local file save location is currently set to the default location.")
Else
{
if PrettyMsg("This will return the local file save location to the default setting. Are you sure you would like to proceed?", "question", 2) == "Yes"
{
localFolder = %A_MyDocuments%\Revit
iniLocal.Settings.LocalFolder := localFolder
iniLocal.save()
GuiControl, Settings:, localLocation, %localFolder%
LogMe("Settings", "localLocation", localFolder, "Default")
}
}
Return
SettingsSubLog:
Run, %localLog%
Return