Skip to content

Commit 0d7cdee

Browse files
author
Tomás Méndez Echenagucia
committed
Merge branch 'master' of https://github.com/compas-dev/compas
2 parents 359f620 + 04be792 commit 0d7cdee

File tree

12 files changed

+130
-132
lines changed

12 files changed

+130
-132
lines changed

src/compas/com/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
MatlabProcess
2121
MatlabSession
2222
23+
Rhino
24+
=====
25+
26+
.. autosummary::
27+
:toctree: generated/
28+
:nosignatures:
29+
30+
RhinoClient
31+
2332
ssh
2433
===
2534
@@ -48,10 +57,10 @@ class Client(object):
4857

4958
from .matlab_ import *
5059
from .ssh import *
51-
# from .rhino import *
60+
from .rhino import *
5261

5362
from .matlab_ import __all__ as a
5463
from .ssh import __all__ as b
55-
# from .rhino import __all__ as b
64+
from .rhino import __all__ as b
5665

5766
__all__ = a + b

src/compas/com/rhino/client.py

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ class RhinoClient(object):
4444
"""
4545

4646
def __init__(self, delay_start=False):
47-
self.app = None
48-
self.rsm = None
49-
self.rsi = None
47+
self.Rhino = None
48+
self.rs = None
5049
if not delay_start:
5150
self.start()
52-
self.wait()
51+
# self.wait()
5352

5453
def __getattr__(self, name):
55-
if self.rsi:
56-
method = getattr(self.rsi, name)
54+
if self.rs:
55+
method = getattr(self.rs, name)
5756

5857
def wrapper(*args, **kwargs):
5958
return method(*args, **kwargs)
@@ -63,48 +62,30 @@ def wrapper(*args, **kwargs):
6362
raise RhinoClientError()
6463

6564
def start(self):
66-
# self.rsm = GetModule(['{75B1E1B4-8CAA-43C3-975E-373504024FDB}', 1, 0])
67-
# self.rsm = GetModule(['{1C7A3523-9A8F-4CEC-A8E0-310F580536A7}', 1, 0])
68-
# self.rsm = GetModule(['{814d908a-e25c-493d-97e9-ee3861957f49}', 1, 0])
69-
# self.rsm = GetModule(['{8ABB4303-8057-47AD-BAEB-263965E5565D}', 1, 0])
70-
# self.rsm = GetModule(['{75B1E1B4-8CAA-43C3-975E-373504024FDB}', 1, 0])
71-
R = GetModule(r"C:\Program Files\Rhinoceros 5\System\Rhino5.tlb")
72-
RS = GetModule(r"C:\Program Files\Rhinoceros 5\Plug-ins\RhinoScript.tlb")
73-
74-
print(dir(R))
75-
print(dir(RS))
76-
77-
print('loading script interface...')
78-
79-
attempts = 20
80-
81-
self.app = CreateObject('Rhino5x64.Application')
82-
83-
while attempts:
84-
try:
85-
print('attempt %s' % attempts)
86-
# self.rsi = self.app.GetScriptObject.QueryInterface(self.rsm.IRhinoScript)
87-
# self.rsi = self.app.QueryInterface(self.rsm.IRhino5x64Application).GetScriptObject()
88-
o = self.app.QueryInterface(R.IRhino5x64Interface).GetScriptObject()
89-
self.rsi = o.QueryInterface(RS.IRhinoScript)
90-
break
91-
except Exception as e:
92-
print(e)
93-
time.sleep(0.5)
94-
attempts -= 1
95-
if self.rsi is None:
96-
raise Exception('error loading script interface...')
97-
print('script interface loaded!')
65+
Rhino_tlb = GetModule("C:/Program Files/Rhinoceros 5/System/Rhino5.tlb")
66+
RhinoScript_tlb = GetModule("C:/Program Files/Rhinoceros 5/Plug-ins/RhinoScript.tlb")
67+
self.Rhino = CreateObject('Rhino5x64.Application').QueryInterface(Rhino_tlb.IRhino5x64Application)
68+
while not self.Rhino.IsInitialized():
69+
print('Initialising Rhino...')
70+
time.sleep(0.5)
71+
print('Rhino initialised!')
72+
self.rs = self.Rhino.GetScriptObject().QueryInterface(RhinoScript_tlb.IRhinoScript)
9873

9974
def stop(self):
10075
raise NotImplementedError
10176

102-
def show(self, flag=1):
103-
self.app.Visible = flag
77+
def show(self):
78+
self.Rhino.Visible = True
10479

105-
def wait(self):
106-
self.rsi.GetString('Press enter to exit...', 'exit')
107-
self.rsi.Command('_Exit')
80+
def hide(self):
81+
self.Rhino.Visible = False
82+
83+
def top(self):
84+
self.Rhino.BringToTop()
85+
86+
# def wait(self):
87+
# self.rs.GetString('Press enter to exit...', 'exit')
88+
# self.rs.Command('_Exit')
10889

10990

11091
# ==============================================================================
@@ -113,5 +94,9 @@ def wait(self):
11394

11495
if __name__ == "__main__":
11596

116-
client = RhinoClient()
117-
client.rsi.AddPoint([0, 0, 0])
97+
Rhino = RhinoClient()
98+
99+
Rhino.show()
100+
Rhino.top()
101+
102+
Rhino.rs.AddPoint([0, 0, 0])

src/compas/hpc/core/euler/euler.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def load_euler_module(client, module):
7575
-------
7676
None
7777
"""
78-
ssh.server_command(client=client, command='module load {0}; module list'.format(module))
78+
ssh.server_command(client=client, command='module load {0}: module list'.format(module))
7979

8080

8181
# def loaded_euler_modules(client):
@@ -98,8 +98,8 @@ def recieve_file_from_euler(username, remote_file, local_file):
9898
Parameters
9999
----------
100100
username (str): Username.
101-
remote_file (str); Path of remote file to recieve.
102-
local_file (str); Path to save local file as.
101+
remote_file (str): Path of remote file to recieve.
102+
local_file (str): Path to save local file as.
103103
104104
Returns
105105
-------
@@ -114,7 +114,7 @@ def send_file_to_euler(username, local_file):
114114
Parameters
115115
----------
116116
username (str): Username.
117-
local_file (str); Path of local file to send.
117+
local_file (str): Path of local file to send.
118118
119119
Returns
120120
-------
@@ -129,7 +129,7 @@ def send_folder_to_euler(username, local_folder):
129129
Parameters
130130
----------
131131
username (str): Username.
132-
local_folder (str); Path of local folder to send.
132+
local_folder (str): Path of local folder to send.
133133
134134
Returns
135135
-------
@@ -236,7 +236,7 @@ def submit_job(client, command, time='60', output='output.txt', cpus=1):
236236
None
237237
"""
238238
n = min([24, int(cpus)])
239-
cmd = 'export OMP_NUM_THREADS={0}; bsub -n {0} -W {1} -oo {2} {3}; bbjobs'.format(n, int(time), output, command)
239+
cmd = 'export OMP_NUM_THREADS={0}: bsub -n {0} -W {1} -oo {2} {3}: bbjobs'.format(n, int(time), output, command)
240240
ssh.server_command(client=client, command=cmd)
241241

242242

@@ -250,8 +250,8 @@ def sync_folder_to_euler(username, local_folder, remote_folder):
250250
Parameters
251251
----------
252252
username (str): Username.
253-
local_folder (str); Path of local folder to sync.
254-
remote_folder (str); Path of remote folder to sync.
253+
local_folder (str): Path of local folder to sync.
254+
remote_folder (str): Path of remote folder to sync.
255255
256256
Returns
257257
-------

src/compas/numerical/algorithms/dr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
34

45
from copy import deepcopy
56

67
from compas.geometry import norm_vectors
78
from compas.topology import adjacency_from_edges
89

910

10-
__author__ = ['Tom Van Mele <[email protected]>']
11-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
12-
__license__ = 'MIT License'
13-
__email__ = '[email protected]'
11+
__author__ = ['Tom Van Mele <[email protected]>']
12+
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
13+
__license__ = 'MIT License'
14+
__email__ = '[email protected]'
1415

1516

1617
__all__ = [

src/compas/numerical/algorithms/dr_numpy.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
34

45
import sys
56

@@ -20,10 +21,10 @@
2021
from compas.numerical import normrow
2122

2223

23-
__author__ = ['Tom Van Mele <[email protected]>']
24-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
25-
__license__ = 'MIT License'
26-
__email__ = '[email protected]'
24+
__author__ = ['Tom Van Mele <[email protected]>']
25+
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
26+
__license__ = 'MIT License'
27+
__email__ = '[email protected]'
2728

2829

2930
__all__ = [

src/compas/numerical/algorithms/drx_numpy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
32
from __future__ import division
3+
from __future__ import print_function
44

55
import sys
66

@@ -30,10 +30,10 @@
3030
from time import time
3131

3232

33-
__author__ = ['Andrew Liew <[email protected]>']
34-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
35-
__license__ = 'MIT License'
36-
__email__ = '[email protected]'
33+
__author__ = ['Andrew Liew <[email protected]>']
34+
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
35+
__license__ = 'MIT License'
36+
__email__ = '[email protected]'
3737

3838

3939
__all__ = [

src/compas/numerical/algorithms/fd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
34

45

5-
__author__ = ['Tom Van Mele', ]
6-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
7-
__license__ = 'MIT'
8-
__email__ = '[email protected]'
6+
__author__ = ['Tom Van Mele', ]
7+
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
8+
__license__ = 'MIT'
9+
__email__ = '[email protected]'
910

1011

1112
__all__ = [
@@ -40,7 +41,6 @@ def fd(vertices, edges, fixed, q, loads):
4041
4142
``xyz, q, f, l, r`` as arrays.
4243
43-
4444
Example
4545
-------
4646
.. plot::

src/compas/numerical/algorithms/fd_cpp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
32
from __future__ import division
3+
from __future__ import print_function
44

55
import os
66
import ctypes
@@ -16,7 +16,7 @@
1616

1717

1818
__author__ = ['Tom Van Mele', ]
19-
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
19+
__copyright__ = 'Copyright 2017 - Block Research Group, ETH Zurich'
2020
__license__ = 'MIT License'
2121
__email__ = '[email protected]'
2222

src/compas/numerical/algorithms/fd_numpy.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from __future__ import print_function
21
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
34

45
import sys
56

@@ -16,10 +17,10 @@
1617
from compas.numerical import normrow
1718

1819

19-
__author__ = ['Tom Van Mele', ]
20-
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
21-
__license__ = 'MIT'
22-
__email__ = '[email protected]'
20+
__author__ = ['Tom Van Mele', ]
21+
__copyright__ = 'Copyright 2017, Block Research Group - ETH Zurich'
22+
__license__ = 'MIT'
23+
__email__ = '[email protected]'
2324

2425

2526
__all__ = [

src/compas/numerical/algorithms/pca_numpy.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import print_function
22
from __future__ import absolute_import
3+
from __future__ import division
34

45
import sys
56

@@ -12,10 +13,10 @@
1213
raise
1314

1415

15-
__author__ = ['Tom Van Mele <[email protected]>']
16-
__copyright__ = 'Copyright 2016, BLOCK Research Group - ETH Zurich'
17-
__license__ = 'MIT License'
18-
__email__ = '[email protected]'
16+
__author__ = ['Tom Van Mele <[email protected]>']
17+
__copyright__ = 'Copyright 2017, BLOCK Research Group - ETH Zurich'
18+
__license__ = 'MIT License'
19+
__email__ = '[email protected]'
1920

2021

2122
__all__ = [

0 commit comments

Comments
 (0)