Skip to content

Commit 458fdab

Browse files
committed
Fix MAC issues
1 parent 6586cf6 commit 458fdab

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

recurring_publish.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import re
33
import tkinter as tk
44
import subprocess
5+
import platform
56
from archicad import ACConnection
67
from tkinter import filedialog, messagebox
78
from datetime import datetime, timedelta
89
from threading import Timer
910

1011
################################ CONFIGURATION #################################
11-
dialogSize = '800x450'
12+
dialogSize = '800x480'
1213
dialogTitle = 'Recurring Publish'
1314
textProject = 'Project:'
1415
textTeamworkUsername = 'Username:'
@@ -74,10 +75,24 @@ def CheckAdditionalJSONCommands ():
7475
messagebox.showerror (errorMessageTitleAdditionalCommandsNotFound, errorMessageDetailsAdditionalCommandsNotFound)
7576
exit ()
7677

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+
7790
def GetArchicadLocation ():
7891
response = acc.ExecuteAddOnCommand (act.AddOnCommandId ('AdditionalJSONCommands', 'GetArchicadLocation'))
7992
if not response or 'archicadLocation' not in response:
8093
messagebox.showerror (errorMessageTitleCommandExecutionFailed, response)
94+
if IsUsingMacOS ():
95+
return f"{response['archicadLocation']}/Contents/MacOS/ARCHICAD"
8196
return response['archicadLocation']
8297

8398
def GetProjectInfo ():
@@ -136,7 +151,7 @@ def RestartArchicad (self):
136151
ReconnectToArchicad ()
137152
global conn
138153
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)
140155
while not conn:
141156
ReconnectToArchicad ()
142157

0 commit comments

Comments
 (0)