Skip to content

Commit 07e0486

Browse files
authored
Merge pull request #16 from ibois-epfl/comp_mac
Compatibility for MAC for script-sync grasshopper
2 parents 966bbb8 + 33d2d3f commit 07e0486

File tree

4 files changed

+175
-42
lines changed

4 files changed

+175
-42
lines changed

.gitignore

Lines changed: 168 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,171 @@ temp/
2828
# General
2929
######################
3030
# get rid of all build folders
31-
build/
31+
build/
32+
33+
######################
34+
# Python
35+
######################
36+
37+
# Byte-compiled / optimized / DLL files
38+
__pycache__/
39+
*.py[cod]
40+
*$py.class
41+
42+
# C extensions
43+
*.so
44+
45+
# Distribution / packaging
46+
.Python
47+
build/
48+
develop-eggs/
49+
dist/
50+
downloads/
51+
eggs/
52+
.eggs/
53+
lib/
54+
lib64/
55+
parts/
56+
sdist/
57+
var/
58+
wheels/
59+
share/python-wheels/
60+
*.egg-info/
61+
.installed.cfg
62+
*.egg
63+
MANIFEST
64+
65+
# PyInstaller
66+
# Usually these files are written by a python script from a template
67+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
68+
*.manifest
69+
*.spec
70+
71+
# Installer logs
72+
pip-log.txt
73+
pip-delete-this-directory.txt
74+
75+
# Unit test / coverage reports
76+
htmlcov/
77+
.tox/
78+
.nox/
79+
.coverage
80+
.coverage.*
81+
.cache
82+
nosetests.xml
83+
coverage.xml
84+
*.cover
85+
*.py,cover
86+
.hypothesis/
87+
.pytest_cache/
88+
cover/
89+
90+
# Translations
91+
*.mo
92+
*.pot
93+
94+
# Django stuff:
95+
*.log
96+
local_settings.py
97+
db.sqlite3
98+
db.sqlite3-journal
99+
100+
# Flask stuff:
101+
instance/
102+
.webassets-cache
103+
104+
# Scrapy stuff:
105+
.scrapy
106+
107+
# Sphinx documentation
108+
docs/_build/
109+
110+
# PyBuilder
111+
.pybuilder/
112+
target/
113+
114+
# Jupyter Notebook
115+
.ipynb_checkpoints
116+
117+
# IPython
118+
profile_default/
119+
ipython_config.py
120+
121+
# pyenv
122+
# For a library or package, you might want to ignore these files since the code is
123+
# intended to run in multiple environments; otherwise, check them in:
124+
# .python-version
125+
126+
# pipenv
127+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
128+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
129+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
130+
# install all needed dependencies.
131+
#Pipfile.lock
132+
133+
# poetry
134+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
135+
# This is especially recommended for binary packages to ensure reproducibility, and is more
136+
# commonly ignored for libraries.
137+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
138+
#poetry.lock
139+
140+
# pdm
141+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
142+
#pdm.lock
143+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
144+
# in version control.
145+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
146+
.pdm.toml
147+
.pdm-python
148+
.pdm-build/
149+
150+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
151+
__pypackages__/
152+
153+
# Celery stuff
154+
celerybeat-schedule
155+
celerybeat.pid
156+
157+
# SageMath parsed files
158+
*.sage.py
159+
160+
# Environments
161+
.env
162+
.venv
163+
env/
164+
venv/
165+
ENV/
166+
env.bak/
167+
venv.bak/
168+
169+
# Spyder project settings
170+
.spyderproject
171+
.spyproject
172+
173+
# Rope project settings
174+
.ropeproject
175+
176+
# mkdocs documentation
177+
/site
178+
179+
# mypy
180+
.mypy_cache/
181+
.dmypy.json
182+
dmypy.json
183+
184+
# Pyre type checker
185+
.pyre/
186+
187+
# pytype static type analyzer
188+
.pytype/
189+
190+
# Cython debug symbols
191+
cython_debug/
192+
193+
# PyCharm
194+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
195+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
196+
# and can be added to the global gitignore or merged into this file. For a more nuclear
197+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
198+
#.idea/

GH/PyGH/components/scriptsynccpy/code.py

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import System
44
import System.Drawing
5-
import System.Windows.Forms
65
import Rhino
6+
import rhinoscriptsyntax as rs
77
import Grasshopper
88
import Grasshopper as gh
99
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
@@ -173,7 +173,7 @@ def handle_connection_error(self, e):
173173
error_messages = {
174174
ConnectionRefusedError: "script-sync::Connection refused by the vscode",
175175
ConnectionResetError: "script-sync::Connection was forcibly closed by the vscode",
176-
socket.error: f"script-sync::Error connecting to the vscode: {str(e)}"
176+
socket.error: f"script-sync::Error connecting to the vscode: {str(e)}, have you tried to press Shift+F4 on VSCode?"
177177
}
178178
self.add_runtime_warning(error_messages[type(e)])
179179
self.is_connected = False if type(e) != socket.error or e.winerror != 10056 else True
@@ -213,37 +213,6 @@ def is_file_modified(self, last_modified):
213213
return current_modified
214214
return last_modified
215215

216-
class DialogThread(threading.Thread):
217-
"""
218-
A vanilla thread to open a dialog to select a file. The windows form
219-
is done in a thread because sometimes it blocks the main thread on which
220-
the Grasshopper canvas is running.
221-
"""
222-
def __init__(self):
223-
threading.Thread.__init__(self)
224-
self.path = None
225-
226-
def run(self):
227-
"""
228-
Open a dialog to select a Python file.
229-
"""
230-
dialog = System.Windows.Forms.OpenFileDialog()
231-
dialog.Filter = "Python files (*.py)|*.py"
232-
dialog.Title = "Select a Python file"
233-
dialog.InitialDirectory = os.path.dirname("")
234-
dialog.FileName = ""
235-
dialog.Multiselect = False
236-
dialog.CheckFileExists = True
237-
dialog.CheckPathExists = True
238-
dialog.RestoreDirectory = True
239-
240-
if dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK:
241-
self.path = dialog.FileName
242-
else:
243-
raise Exception("script-sync::File not selected")
244-
245-
246-
247216
class ScriptSyncCPy(component):
248217
def __init__(self):
249218
super(ScriptSyncCPy, self).__init__()
@@ -290,13 +259,10 @@ def init_script_path(self, select_file : bool = False):
290259
"""
291260
# check if button is pressed
292261
if select_file is True:
293-
dialog_thread = DialogThread()
294-
dialog_thread.start()
295-
dialog_thread.join() # Wait for the dialog to close
296-
if dialog_thread.path is not None:
297-
self.path = dialog_thread.path
298-
else:
299-
raise Exception("script-sync::File not selected")
262+
filename = rs.OpenFileName("Open", "Python Files (*.py)|*.py||")
263+
if filename is None:
264+
raise Exception("script-sync::No file selected")
265+
self.path = filename
300266

301267
# fi file is in table view before
302268
if not os.path.exists(self.path):
Binary file not shown.

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: script-sync
3-
version: 1.1.24
3+
version: 1.2.0
44
authors:
55
- Andrea Settimi
66
description: Script-sync is a Rhino plug-in to run C# and Python (IronPython or CPython) in RhinoV8.

0 commit comments

Comments
 (0)