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