1 |
import extpy |
2 |
|
3 |
try: |
4 |
from pylab import * |
5 |
except: |
6 |
pass |
7 |
|
8 |
from solverreporter import * |
9 |
|
10 |
def fourbarplot(self): |
11 |
"""Plot the geometry of the four-bar linkage""" |
12 |
# following is an unfortunate necessity in the current system architecture: |
13 |
|
14 |
import loading |
15 |
loading.load_matplotlib(throw=True) |
16 |
|
17 |
browser = extpy.getbrowser() |
18 |
browser.do_solve() |
19 |
|
20 |
ioff() |
21 |
figure() |
22 |
gca().set_aspect('equal', adjustable='datalim') |
23 |
hold(True) |
24 |
|
25 |
for alpha in range(10,74,4): |
26 |
self.alpha.setRealValueWithUnits(alpha,"deg") |
27 |
try: |
28 |
browser.sim.solve(browser.solver,SimpleSolverReporter(browser)) |
29 |
except: |
30 |
browser.reporter.reportError('Failed to solve for alpha = %d' % alpha) |
31 |
continue |
32 |
|
33 |
x = [float(x) for x in [self.x_A, self.x_B, self.x_C, self.x_D]] |
34 |
y = [float(y) for y in [self.y_A, self.y_B, self.y_C, self.y_D]] |
35 |
|
36 |
plot(x,y,"y-") |
37 |
plot(x[0:2],y[0:2],"ro") |
38 |
plot(x[2:4],y[2:4],"bo") |
39 |
|
40 |
extpy.getbrowser().reporter.reportNote("Plotting completed") |
41 |
ion() |
42 |
show() |
43 |
|
44 |
extpy.registermethod(fourbarplot) |
45 |
#the above method can be called using "EXTERNAL fourbarplot(SELF)" in ASCEND. |