|
2 | 2 | import re |
3 | 3 | import tkinter as tk |
4 | 4 | import subprocess |
| 5 | +import platform |
5 | 6 | from archicad import ACConnection |
6 | 7 | from tkinter import filedialog, messagebox |
7 | 8 | from datetime import datetime, timedelta |
8 | 9 | from threading import Timer |
9 | 10 |
|
10 | 11 | ################################ CONFIGURATION ################################# |
11 | | -dialogSize = '800x450' |
| 12 | +dialogSize = '800x480' |
12 | 13 | dialogTitle = 'Recurring Publish' |
13 | 14 | textProject = 'Project:' |
14 | 15 | textTeamworkUsername = 'Username:' |
@@ -74,10 +75,24 @@ def CheckAdditionalJSONCommands (): |
74 | 75 | messagebox.showerror (errorMessageTitleAdditionalCommandsNotFound, errorMessageDetailsAdditionalCommandsNotFound) |
75 | 76 | exit () |
76 | 77 |
|
| 78 | +def IsUsingMacOS (): |
| 79 | + return platform.system () == 'Darwin' |
| 80 | + |
| 81 | +def IsUsingWindows (): |
| 82 | + return platform.system () == 'Windows' |
| 83 | + |
| 84 | +def EscapeSpacesInPath (path): |
| 85 | + if IsUsingWindows (): |
| 86 | + return f'"{path}"' |
| 87 | + else: |
| 88 | + return path.replace (' ', '\\ ') |
| 89 | + |
77 | 90 | def GetArchicadLocation (): |
78 | 91 | response = acc.ExecuteAddOnCommand (act.AddOnCommandId ('AdditionalJSONCommands', 'GetArchicadLocation')) |
79 | 92 | if not response or 'archicadLocation' not in response: |
80 | 93 | messagebox.showerror (errorMessageTitleCommandExecutionFailed, response) |
| 94 | + if IsUsingMacOS (): |
| 95 | + return f"{response['archicadLocation']}/Contents/MacOS/ARCHICAD" |
81 | 96 | return response['archicadLocation'] |
82 | 97 |
|
83 | 98 | def GetProjectInfo (): |
@@ -136,7 +151,7 @@ def RestartArchicad (self): |
136 | 151 | ReconnectToArchicad () |
137 | 152 | global conn |
138 | 153 | if not conn: |
139 | | - subprocess.Popen ([archicadLocation, projectInfo['projectLocation']], start_new_session=True) |
| 154 | + subprocess.Popen (f"{EscapeSpacesInPath (archicadLocation)} {EscapeSpacesInPath (projectInfo['projectLocation'])}", start_new_session=True, shell=True) |
140 | 155 | while not conn: |
141 | 156 | ReconnectToArchicad () |
142 | 157 |
|
|
0 commit comments