PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Program_Files/replicatorg-0025/skein_engines/skeinforge-31/skeinforge_application/skeinforge.py

https://github.com/sialan/autonomous-sprayer
Python | 597 lines | 537 code | 26 blank | 34 comment | 24 complexity | 5213624c8ae28d075292b5c3b3d5b2b4 MD5 | raw file
  1. #!/usr/bin/python
  2. """
  3. This page is in the table of contents.
  4. ==Overview==
  5. ===Introduction===
  6. Skeinforge is a GPL tool chain to forge a gcode skein for a model.
  7. The tool chain starts with carve, which carves the model into layers, then the layers are modified by other tools in turn like fill, comb, tower, raft, stretch, hop, wipe, fillet & export. Each tool automatically gets the gcode from the previous tool. So if you want a carved & filled gcode, call the fill tool and it will call carve, then it will fill and output the gcode. If you want to use all the tools, call export and it will call in turn all the other tools down the chain to produce the gcode file.
  8. If you do not want a tool after preface to modify the output, deselect the Activate checkbox for that tool. When the Activate checkbox is off, the tool will just hand off the gcode to the next tool without modifying it.
  9. The skeinforge module provides a single place to call up all the setting dialogs. When the 'Skeinforge' button is clicked, skeinforge calls export, since that is the end of the chain.
  10. The plugin buttons which are commonly used are bolded and the ones which are rarely used have normal font weight.
  11. There are also tools which handle settings for the chain, like polyfile.
  12. The analyze tool calls plugins in the analyze_plugins folder, which will analyze the gcode in some way when it is generated if their Activate checkbox is selected.
  13. The interpret tool accesses and displays the import plugins.
  14. The default settings are similar to those on Nophead's machine. A setting which is often different is the 'Layer Thickness' in carve.
  15. ===Alternative===
  16. Another way to make gcode for a model is to use the Java RepRap host program, described at:
  17. http://reprap.org/wiki/Installing_RepRap_on_your_computer
  18. ===Contribute===
  19. You can contribute by helping develop the manual at:
  20. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge
  21. There is also a forum thread about how to contribute to skeinforge development at:
  22. http://dev.forums.reprap.org/read.php?12,27562
  23. I will only reply to emails from contributors or to complete bug reports.
  24. ===Documentation===
  25. There is a manual at:
  26. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge
  27. There is also documentation is in the documentation folder, in the doc strings for each module and it can be called from the '?' button or the menu or by clicking F1 in each setting dialog.
  28. A list of other tutorials is at:
  29. http://www.bitsfrombytes.com/wiki/index.php?title=Skeinforge#Tutorials
  30. ===Fabrication===
  31. To fabricate a model with gcode and the Arduino you can use the send.py in the fabricate folder. The documentation for it is in the folder as send.html and at:
  32. http://reprap.org/bin/view/Main/ArduinoSend
  33. Another way is to use an EMC2 or similar computer controlled milling machine, as described in the "ECM2 based repstrap" forum thread at:
  34. http://forums.reprap.org/read.php?1,12143
  35. using the M-Apps package, which is at:
  36. http://forums.reprap.org/file.php?1,file=772
  37. Another way is to use Zach's ReplicatorG at:
  38. http://replicat.org/
  39. There is also an older Processing script at:
  40. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/hoeken/arduino/GCode_Host/
  41. Yet another way is to use the reprap host, written in Java, to load and print gcode:
  42. http://dev.www.reprap.org/bin/view/Main/DriverSoftware#Load_GCode
  43. For jogging, the Metalab group wrote their own exerciser, also in Processing:
  44. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/metalab/processing/GCode_Exerciser/
  45. The Metalab group has descriptions of skeinforge in action and their adventures are described at:
  46. http://reprap.soup.io/
  47. There is a board about printing issues at:
  48. http://www.bitsfrombytes.com/fora/user/index.php?board=5.0
  49. You can buy the Rapman (an improved Darwin) from Bits from Bytes at:
  50. http://www.bitsfrombytes.com/
  51. You can buy the Makerbot from Makerbot Industries at:
  52. http://www.makerbot.com/
  53. ===File Formats===
  54. An explanation of the gcodes is at:
  55. http://reprap.org/bin/view/Main/Arduino_GCode_Interpreter
  56. and at:
  57. http://reprap.org/bin/view/Main/MCodeReference
  58. A gode example is at:
  59. http://forums.reprap.org/file.php?12,file=565
  60. The settings are saved as tab separated .csv files in the .skeinforge folder in your home directory. The settings can be set in the tool dialogs. The .csv files can also be edited with a text editor or a spreadsheet program set to separate tabs.
  61. The Scalable Vector Graphics file produced by vectorwrite can be opened by an SVG viewer or an SVG capable browser like Mozilla:
  62. http://www.mozilla.com/firefox/
  63. A good triangle surface format is the GNU Triangulated Surface format, which is supported by Mesh Viewer and described at:
  64. http://gts.sourceforge.net/reference/gts-surfaces.html#GTS-SURFACE-WRITE
  65. You can export GTS files from Art of Illusion with the Export GNU Triangulated Surface.bsh script in the Art of Illusion Scripts folder.
  66. STL is an inferior triangle surface format, described at:
  67. http://en.wikipedia.org/wiki/STL_(file_format)
  68. If you're using an STL file and you can't even carve it, try converting it to a GNU Triangulated Surface file in Art of Illusion. If it still doesn't carve, then follow the advice in the troubleshooting section.
  69. ===Getting Skeinforge===
  70. The latest version is at:
  71. http://members.axion.net/~enrique/reprap_python_beanshell.zip
  72. a sometimes out of date version is in the last reprap_python_beanshell.zip attachment in the last post of the Fabmetheus blog at:
  73. http://fabmetheus.blogspot.com/
  74. another sometimes out of date version is at:
  75. https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/reprap/miscellaneous/python-beanshell-scripts/
  76. ===Getting Started===
  77. For skeinforge to run, install python 2.x on your machine, which is available from:
  78. http://www.python.org/download/
  79. To use the settings dialog you'll also need Tkinter, which probably came with the python installation. If it did not, look for it at:
  80. http://www.tcl.tk/software/tcltk/
  81. If you want python and Tkinter together on MacOS, you can try:
  82. http://www.astro.washington.edu/users/rowen/ROPackage/Overview.html
  83. If you want python and Tkinter together on all platforms and don't mind filling out forms, you can try the ActivePython package from Active State at:
  84. http://www.activestate.com/Products/activepython/feature_list.mhtml
  85. The computation intensive python modules will use psyco if it is available and run about twice as fast. Psyco is described at:
  86. http://psyco.sourceforge.net/index.html
  87. The psyco download page is:
  88. http://psyco.sourceforge.net/download.html
  89. Skeinforge imports Stereolithography (.stl) files or GNU Triangulated Surface (.gts) files. If importing an STL file directly doesn't work, an indirect way to import an STL file is by turning it into a GTS file is by using the Export GNU Triangulated Surface script at:
  90. http://members.axion.net/~enrique/Export%20GNU%20Triangulated%20Surface.bsh
  91. The Export GNU Triangulated Surface script is also in the Art of Illusion folder, which is in the same folder as skeinforge.py. To bring the script into Art of Illusion, drop it into the folder ArtOfIllusion/Scripts/Tools/. Then import the STL file using the STL import plugin in the import submenu of the Art of Illusion file menu. Then from the Scripts submenu in the Tools menu, choose 'Export GNU Triangulated Surface' and select the imported STL shape. Click the 'Export Selected' checkbox and click OK. Once you've created the GTS file, you can turn it into gcode by typing in a shell in the same folder as skeinforge:
  92. > python skeinforge.py
  93. When the skeinforge dialog pops up, click 'Skeinforge', choose the file which you exported in 'Export GNU Triangulated Surface' and the gcode file will be saved with the suffix '_export.gcode'.
  94. Or you can turn files into gcode by adding the file name, for example:
  95. > python skeinforge.py Screw Holder Bottom.stl
  96. ===Motto===
  97. I may be slow, but I get there in the end.
  98. ===Troubleshooting===
  99. If there's a bug, try downloading the very latest version because skeinforge is often updated without an announcement.
  100. If there is still a bug, then first prepare the following files:
  101. 1. stl file
  102. 2. pictures explaining the problem
  103. 3. your settings (pack the whole .skeinforge directory with all your settings)
  104. Then zip all the files.
  105. Second, write a description of the error, send the description and the archive to the developer, enrique ( perez_enrique AT yahoo.com.removethispart ). After a bug fix is released, test the new version and report the results to enrique, whether the fix was successful or not.
  106. If the dialog window is too big for the screen, on most Linux window managers you can move a window by holding down the Alt key and then drag the window with the left mouse button to get to the off screen widgets.
  107. If you can't use the graphical interface, you can change the settings for skeinforge by using a text editor or spreadsheet to change the settings in the profiles folder in the .skeinforge folder in your home directory.
  108. Comments and suggestions are welcome, however, I won't reply unless you are a contributor because developing takes all my time and as of the time of this writing I have at least three years of features to implement.
  109. I will only answer your questions if you contribute to skeinforge in some way. Some ways of contributing to skeinforge are in the contributions thread at:
  110. http://dev.forums.reprap.org/read.php?12,27562
  111. I reserve the right to make any correspondence public. Do not send me any correspondence marked confidential. If you do I will delete it.
  112. ==Examples==
  113. The following examples forge the STL file Screw Holder.stl. The examples are run in a terminal in the folder which contains Screw Holder.gts and skeinforge.py.
  114. > python skeinforge.py
  115. This brings up the dialog, after clicking 'Skeinforge', the following is printed:
  116. The exported file is saved as Screw Holder_export.gcode
  117. > python skeinforge.py Screw Holder.stl
  118. The exported file is saved as Screw Holder_export.gcode
  119. > python
  120. Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)
  121. [GCC 4.2.1 (SUSE Linux)] on linux2
  122. Type "help", "copyright", "credits" or "license" for more information.
  123. >>> import skeinforge
  124. >>> skeinforge.writeOutput('Screw Holder.stl')
  125. The exported file is saved as Screw Holder_export.gcode
  126. >>> skeinforge.main()
  127. This brings up the skeinforge dialog.
  128. To run only fill for example, type in the skeinforge_plugins folder which fill is in:
  129. > python fill.py
  130. """
  131. from __future__ import absolute_import
  132. import __init__
  133. from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
  134. from fabmetheus_utilities import euclidean
  135. from fabmetheus_utilities import gcodec
  136. from fabmetheus_utilities import settings
  137. from fabmetheus_utilities import archive
  138. from skeinforge_application.skeinforge_utilities import skeinforge_craft
  139. from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
  140. from skeinforge_application.skeinforge_utilities import skeinforge_profile
  141. from optparse import OptionParser
  142. import os
  143. import sys
  144. # get bevel profile, bevel rack, rack extended, annulus layer, annulus from teeth, annulus solid, annulus helix
  145. # negative radius for annulus inverted, thin annulus teeth, toothProfile input
  146. # rack, hole input
  147. # test grid types
  148. # get list of XMLElements for paths
  149. # <alteration>
  150. # bottom
  151. # speed into speed and limit
  152. # mirror axis center & origin, concatenate
  153. # matrixTetragrid to tetragrid, matrix.transform, target
  154. # maybe matrix array form a00 a01.. also
  155. # matrix rotate around axis http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations
  156. # linear bearing
  157. # grate separate
  158. # xml_creation
  159. # fill rename shortenedSegmentList gridSegmentList and delete comments
  160. # array paths, follow paths, later maybe targetequation radius xyz give index
  161. # writeTagged, tags, creationTags, writeMatrix='true'
  162. # bottom plugin
  163. # connectionfrom, to, connect, xaxis
  164. # if there are no problems with getDescendingAreaLoops(allPoints, corners, importRadius) replace getInclusiveLoops, also replace getOverlapRatio with getOverlap
  165. # add overview link to crnsdoo index and svg page
  166. # bound.bottom to cube, sphere, cylinder input, maybe mesh., bound.bottom & left & right & top for xy plane
  167. # look over copy module, make copy solid like copy lineation
  168. # document gear script
  169. # big save, initial circling moved to raft from temperature
  170. #
  171. # classify more of evaluate.xml
  172. # maybe in svgReader if loop intersection with previous union else add
  173. #
  174. # unimportant
  175. # minor outline problem when an end path goes through a path, like in the letter A
  176. # carve time is missing
  177. # view profile 1 mm thickness
  178. # svg inskcape layer label, import into inskscape in general
  179. # only parse svg once, do not parse again if yAxisPointingUpward="true"
  180. # getControlPoints, also handle no controlPoint in which case make coincident
  181. # maybe vector3 relative to previous
  182. #
  183. # close, getPillarByLoopLists, addConcave, polymorph original graph section, loop, add step object, add continuous object
  184. # del previous, add begin & end if far get actual path
  185. # polling
  186. # svgCanvas with xmlWriter instead of directly writing
  187. # speed up CircleIntersection by performing isWithinCircles before creation
  188. # getNormal, getIsFlat?
  189. # write svg for visible paths
  190. # distance in equation
  191. # combine xmlelement with csvelement using example.csv & geometry.csv, csv _format, _column, _row, _text
  192. # getConnection of some kind like getConnectionVertexes, getConnection
  193. # import module, overwriteRoot
  194. # pixel, voxel, surfaxel/boxel, lattice, mesh
  195. # equation for vertexes if not already
  196. # mesh. for cube, then cyliner, then sphere after lathe
  197. # extrude take radius
  198. # tube
  199. # rotor
  200. # test translate
  201. # lathe
  202. # think about setActualMinimumZ in boolean_geometry
  203. # pyramid
  204. # round extrusion ?, fillet
  205. # manipulate solid, maybe manipulate around elements
  206. # hollow top
  207. # boolean loop corner outset
  208. # work out close and radius
  209. # voronoi average location intersection looped inset intercircles
  210. # maybe move and give geometryOutput to cube, cylinder, sphere
  211. #
  212. # comb -> maybe add back running jump look at outside loops only for jump, find closest points, find slightly away inside points, link
  213. # global simplify pathBetween
  214. # comb documentation
  215. # maybe move after clip
  216. #
  217. # stretch add back addAlong
  218. # maybe save all generated_files option
  219. # creationID, addObject, getTarget, copyXMLElement?
  220. # drill
  221. # dovetail
  222. # maybe not getNewObject, getNew, addToBoolean
  223. # convert global repository settings to local settings
  224. # table to dictionary
  225. # maybe try to get rid of comment if possible
  226. # check for last existing then remove unneeded fill code (getLastExistingFillLoops) from euclidean
  227. # remove cool set at end of layer
  228. # add fan on when hot in chamber
  229. # maybe measuring rod
  230. # remove comments from clip, bend
  231. # winding into coiling, coil into wind & weave
  232. # later, precision
  233. # documentation
  234. # http://wiki.makerbot.com/configuring-skeinforge
  235. #
  236. #
  237. # add hook _extrusion
  238. # implement acceleration & collinear removal in penultimate viewers _extrusion
  239. # integral thin width _extrusion
  240. # layer color, for multilayer start http://reprap.org/pub/Main/MultipleMaterialsFiles/legend.xml _extrusion
  241. # maybe double height shells option _extrusion
  242. # raft triple layer base, middle interface with hot loop or ties
  243. # somehow, add pattern to outside, http://blog.makerbot.com/2010/09/03/lampshades/
  244. #
  245. # arch, ceiling
  246. # add polish, has perimeter, has cut first layer (False)
  247. # probably not set addedLocation in distanceFeedRate after arc move
  248. # maybe horizontal bridging and/or check to see if the ends are standing on anything
  249. # thin self? check when removing intersecting paths in inset
  250. # maybe later remove isPerimeterPathInSurroundLoops, once there are no weird fill bugs, also change getHorizontalSegmentListsFromLoopLists
  251. # save all analyze viewers of the same name except itself, update help menu self.wikiManualPrimary.setUpdateFunction
  252. # check alterations folder first, if there is something copy it to the home directory, if not check the home directory
  253. # set temperature in temperature
  254. # move alterations and profiles to top level
  255. #
  256. #
  257. #
  258. # help primary menu item refresh
  259. # add plugin help menu, add craft below menu
  260. # give option of saving when switching profiles
  261. # xml & svg more forgiving, svg make defaults for layerThickness, maxZ, minZ, add layer z to svg_template, make the slider on the template track even when mouse is outside
  262. # option of surrounding lines in display
  263. # maybe add connecting line in display line
  264. # maybe check inset loops to see if they are smaller, but this would be slow
  265. # maybe status bar
  266. # maybe measurement ruler mouse tool
  267. # search rss from blogs, add search links for common materials, combine created on or progress bar with searchable help
  268. # boundaries, center radius z bottom top, circular or rectangular, polygon, put cool minimum radius orbits within boundaries
  269. # move & rotate model
  270. # possible jitter bug http://cpwebste.blogspot.com/2010/04/hydras-first-print.html
  271. # trial, meta in a grid settings
  272. # maybe svg slice format
  273. # maybe interpret svg_convex_mesh
  274. #laminate tool head
  275. #maybe use 5x5 radius search in circle node
  276. #maybe add layer updates in behold, skeinview and maybe others
  277. #lathe winding, extrusion and cutting; synonym for rotation or turning, loop angle
  278. # maybe split into source code and documentation sections
  279. # transform plugins, start with sarrus http://www.thingiverse.com/thing:1425
  280. # maybe make setting backups
  281. # maybe settings in gcode or saved versions
  282. # move skeinforge_utilities to fabmetheus_utilities
  283. # maybe lathe cutting
  284. # maybe lathe extrusion
  285. # maybe lathe millng
  286. # maybe lathe winding & weaving
  287. #
  288. #
  289. #
  290. # pick and place
  291. # search items, search links, choice entry field
  292. # svg triangle mesh, svg polygon mesh
  293. # simulate
  294. #transform
  295. #extrude loops I guess make circles? and/or run along sparse infill
  296. #custom inclined plane, inclined plane from model, screw, fillet travel as well maybe
  297. # probably not stretch single isLoop
  298. #maybe much afterwards make congajure multistep view
  299. #maybe stripe although model colors alone can handle it
  300. #stretch fiber around shape, maybe modify winding for asymmetric shapes
  301. #multiple heads around edge
  302. #maybe add full underscored date name for version
  303. #maybe add rarely used tool option
  304. #angle shape for overhang extrusions
  305. #maybe m111? countdown
  306. #common tool
  307. #first time tool tip
  308. #individual tool tip to place in text
  309. # maybe try to simplify raft layer start
  310. # maybe make temp directory
  311. # maybe carve aoi xml testing and check xml gcode
  312. # maybe cross hatch support polishing???
  313. # maybe print svg view from current layer or zero layer in single view
  314. # maybe check if tower is picking the nearest island
  315. # maybe combine skein classes in fillet
  316. # maybe isometric svg option
  317. #Manual
  318. #10,990
  319. #11,1776,786
  320. #12,3304,1528
  321. #1,4960,1656
  322. #2, 7077,2117
  323. #3, 9598,2521
  324. #4 12014,2305
  325. #5 14319,2536
  326. #6 16855,3226
  327. #7 20081, 2189
  328. #8 22270, 2625
  329. #9 24895
  330. #85 jan7, 86jan11, 87 jan13, 88 jan15, 91 jan21, 92 jan23, 95 jan30, 98 feb6
  331. #make one piece electromagnet spool
  332. #stepper rotor with ceramic disk magnet in middle, electromagnet with long thin spool line?
  333. #stepper motor
  334. #make plastic coated thread in vat with pulley
  335. #tensile stuart platform
  336. #kayak
  337. #gear vacuum pump
  338. #gear turbine
  339. #heat engine
  340. #solar power
  341. #sailboat
  342. #yacht
  343. #house
  344. #condo with reflected gardens in between buildings
  345. #medical equipment
  346. #cell counter, etc..
  347. #pipe clamp lathe
  348. # square tube driller & cutter
  349. # archihedrongagglevoteindexium
  350. # outline images
  351. # look from top of intersection circle plane to look for next, add a node; tree out until all are stepped on then connect, when more than three intersections are close
  352. # when loading a file, we should have a preview of the part and orientation in space
  353. # second (and most important in my opinion) would be the ability to rotate the part on X/Y/Z axis to chose it's orientation
  354. # third, a routine to detect the largest face and orient the part accordingly. Mat http://reprap.kumy.net/
  355. # concept, three perpendicular slices to get display spheres
  356. # extend lines around short segment after cross hatched boolean
  357. # concept, teslocracy or citizendium; donation, postponement, rotate ad network, cached search options
  358. # concept, local ad server, every time the program runs it changes the iamge which all the documentation points to from a pool of ads
  359. # concept, join cross slices, go from vertex to two orthogonal edges, then from edges to each other, if not to a common point, then simplify polygons by removing points which do not change the area much
  360. # concept, each node is fourfold, use sorted intersectionindexes to find close, connect each double sided edge, don't overlap more than two triangles on an edge
  361. # concept, diamond cross section loops
  362. # concept, in file, store polygon mesh and centers
  363. # concept, display spheres or polygons would have original triangle for work plane
  364. # .. then again no point with slices
  365. # concept, filled slices, about 2 mm thick
  366. # concept, rgb color triangle switch to get inside color, color golden ratio on 5:11 slope with a modulo 3 face
  367. # concept, interlaced bricks at corners ( length proportional to corner angle )
  368. # concept, new links to archi, import links to archi and adds skeinforge tool menu item, back on skeinforge named execute tool is added
  369. # concept, trnsnt
  370. # concept, indexium expand condense remove, single text, pymetheus
  371. # concept, inscribed key silencer
  372. # concept, spreadsheet to python and/or javascript
  373. # concept, blog, frequent updates, mix associated news
  374. # concept, range voting for posters, informative, complainer, funny, insightful, rude, spammer, literacy, troll?
  375. # concept, intermittent cloud with multiple hash functions
  376. # concept, demodiu xml articles
  377. __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
  378. __credits__ = """
  379. Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
  380. Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
  381. Greenarrow <http://forums.reprap.org/profile.php?12,81>
  382. Ian England <http://forums.reprap.org/profile.php?12,192>
  383. John Gilmore <http://forums.reprap.org/profile.php?12,364>
  384. Jonwise <http://forums.reprap.org/profile.php?12,716>
  385. Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
  386. Michael Duffin <http://forums.reprap.org/profile.php?12,930>
  387. Marius Kintel <http://reprap.soup.io/>
  388. Nophead <http://www.blogger.com/profile/12801535866788103677>
  389. PJR <http://forums.reprap.org/profile.php?12,757>
  390. Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
  391. Wade <http://forums.reprap.org/profile.php?12,489>
  392. Xsainnz <http://forums.reprap.org/profile.php?12,563>
  393. Zach Hoeken <http://blog.zachhoeken.com/>
  394. Organizations:
  395. Art of Illusion <http://www.artofillusion.org/>"""
  396. __date__ = "$Date: 2008/21/11 $"
  397. __license__ = 'GPL 3.0'
  398. def addToProfileMenu( profileSelection, profileType, repository ):
  399. "Add a profile menu."
  400. pluginFileNames = skeinforge_profile.getPluginFileNames()
  401. craftTypeName = skeinforge_profile.getCraftTypeName()
  402. pluginModule = skeinforge_profile.getCraftTypePluginModule()
  403. profilePluginSettings = settings.getReadRepository( pluginModule.getNewRepository() )
  404. for pluginFileName in pluginFileNames:
  405. skeinforge_profile.ProfileTypeMenuRadio().getFromMenuButtonDisplay( profileType, pluginFileName, repository, craftTypeName == pluginFileName )
  406. for profileName in profilePluginSettings.profileList.value:
  407. skeinforge_profile.ProfileSelectionMenuRadio().getFromMenuButtonDisplay( profileSelection, profileName, repository, profileName == profilePluginSettings.profileListbox.value )
  408. def getPluginsDirectoryPath():
  409. "Get the plugins directory path."
  410. return gcodec.getAbsoluteFolderPath( __file__, 'skeinforge_plugins')
  411. def getPluginFileNames():
  412. "Get analyze plugin fileNames."
  413. return gcodec.getPluginFileNamesFromDirectoryPath( getPluginsDirectoryPath() )
  414. def getNewRepository():
  415. "Get the repository constructor."
  416. return SkeinforgeRepository()
  417. def getRadioPluginsAddPluginGroupFrame( directoryPath, importantFileNames, names, repository ):
  418. "Get the radio plugins and add the plugin frame."
  419. repository.pluginGroupFrame = settings.PluginGroupFrame()
  420. radioPlugins = []
  421. for name in names:
  422. radioPlugin = settings.RadioPlugin().getFromRadio( name in importantFileNames, repository.pluginGroupFrame.latentStringVar, name, repository, name == importantFileNames[0] )
  423. radioPlugin.updateFunction = repository.pluginGroupFrame.update
  424. radioPlugins.append( radioPlugin )
  425. defaultRadioButton = settings.getSelectedRadioPlugin( importantFileNames + [ radioPlugins[0].name ], radioPlugins )
  426. repository.pluginGroupFrame.getFromPath( defaultRadioButton, directoryPath, repository )
  427. return radioPlugins
  428. def writeOutput(fileName):
  429. "Craft a gcode file."
  430. skeinforge_craft.writeOutput(fileName)
  431. class SkeinforgeRepository:
  432. "A class to handle the skeinforge settings."
  433. def __init__(self):
  434. "Set the default settings, execute title & settings fileName."
  435. settings.addListsToRepository('skeinforge_application.skeinforge.html', '', self )
  436. self.fileNameInput = settings.FileNameInput().getFromFileName( fabmetheus_interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '')
  437. self.profileType = settings.MenuButtonDisplay().getFromName('Profile Type: ', self )
  438. self.profileSelection = settings.MenuButtonDisplay().getFromName('Profile Selection: ', self )
  439. addToProfileMenu( self.profileSelection, self.profileType, self )
  440. settings.LabelDisplay().getFromName('Search:', self )
  441. reprapSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_reprap.html', 'Reprap', self )
  442. skeinforgeSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_skeinforge.html', 'Skeinforge', self )
  443. skeinforgeSearch.column += 2
  444. webSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_web.html', 'Web', self )
  445. webSearch.column += 4
  446. versionText = gcodec.getFileText( gcodec.getVersionFileName() )
  447. self.version = settings.LabelDisplay().getFromName('Version: ' + versionText, self )
  448. settings.LabelDisplay().getFromName('', self )
  449. importantFileNames = ['craft', 'profile']
  450. getRadioPluginsAddPluginGroupFrame( getPluginsDirectoryPath(), importantFileNames, getPluginFileNames(), self )
  451. self.executeTitle = 'Skeinforge'
  452. def execute(self):
  453. "Skeinforge button has been clicked."
  454. fileNames = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode( self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled )
  455. for fileName in fileNames:
  456. writeOutput(fileName)
  457. def save(self):
  458. "Profile has been saved and profile menu should be updated."
  459. self.profileType.removeMenus()
  460. self.profileSelection.removeMenus()
  461. addToProfileMenu( self.profileSelection, self.profileType, self )
  462. self.profileType.addRadiosToDialog( self.repositoryDialog )
  463. self.profileSelection.addRadiosToDialog( self.repositoryDialog )
  464. def main():
  465. "Display the skeinforge dialog."
  466. parser = OptionParser()
  467. parser.add_option("-p", "--prefdir", help="set path to preference directory",
  468. action="store", type="string", dest="preferencesDirectory")
  469. parser.add_option("-s", "--start", help="set start file to use",
  470. action="store", type="string", dest="startFile")
  471. parser.add_option("-e", "--end", help="set end file to use",
  472. action="store", type="string", dest="endFile")
  473. parser.add_option("-o", "--option",
  474. help='set an individual option in the format "module:preference=value"',
  475. action="append", type="string", dest="preferences")
  476. (options, args) = parser.parse_args()
  477. defaultStart = 'start.txt'
  478. defaultEnd = 'end.txt'
  479. if options.preferencesDirectory:
  480. pdir = options.preferencesDirectory;
  481. archive.setSettingsPath(pdir)
  482. # if options.startFile:
  483. # preferences.setStartFile(options.startFile)
  484. # else:
  485. # preferences.setStartFile(defaultStart)
  486. # if options.endFile:
  487. # preferences.setEndFile(options.endFile)
  488. # else:
  489. # preferences.setEndFile(defaultEnd)
  490. if options.preferences:
  491. for prefSpec in options.preferences:
  492. (moduleName,prefSpec) = prefSpec.split(":",1)
  493. (prefName,valueName) = prefSpec.split("=",1)
  494. settings.addPreferenceOverride(moduleName,prefName,valueName)
  495. sys.argv = [sys.argv[0]] + args
  496. if len( args ) > 0:
  497. writeOutput( ' '.join(args) )
  498. else:
  499. settings.startMainLoopFromConstructor( getNewRepository() )
  500. if __name__ == "__main__":
  501. main()