/[ascend]/trunk/models/johnpye/fourbarplot.py
ViewVC logotype

Contents of /trunk/models/johnpye/fourbarplot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1464 - (show annotations) (download) (as text)
Sun Jun 3 04:09:36 2007 UTC (17 years, 7 months ago) by jpye
File MIME type: text/x-python
File size: 1068 byte(s)
Added 'alert' option to 'loading' module.
Added start menu shortcut to Model Library
Bumped version to 0.9.5.111.
Fixed loading of fourbarplot.py example when matplotlib not available.
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.

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22