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

/skeinforge_application/skeinforge.py

https://github.com/jmil/SFACT
Python | 617 lines | 294 code | 43 blank | 280 comment | 36 complexity | a1f4931cd4115aa8eed2a85fbc6fc6d9 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. ===Command Line Interface===
  16. To bring up the skeinforge dialog without a file name, type:
  17. python skeinforge_application/skeinforge.py
  18. Slicing a file from skeinforge_utilities/skeinforge_craft.py, for example:
  19. python skeinforge_application/skeinforge_utilities/skeinforge_craft.py test.stl
  20. will slice the file and exit. This is the correct option for programs which use skeinforge to only generate a gcode file.
  21. Slicing a file from skeinforge.py, for example:
  22. python skeinforge_application/skeinforge.py test.stl
  23. will slice the file and bring up the skeinforge window and the analyze windows and then skeinforge will wait for user input.
  24. Slicing a file from skeinforge_plugins/craft.py, for example:
  25. python skeinforge_application/skeinforge_plugins/craft.py test.stl
  26. will slice the file and bring up the analyze windows only and then skeinforge will wait for user input.
  27. ===Contribute===
  28. You can contribute by helping develop the manual at:
  29. http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge
  30. There is also a forum thread about how to contribute to skeinforge development at:
  31. http://dev.forums.reprap.org/read.php?12,27562
  32. I will only reply to emails from contributors or to complete bug reports.
  33. ===Documentation===
  34. There is a manual at:
  35. http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge
  36. 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.
  37. A list of other tutorials is at:
  38. http://fabmetheus.crsndoo.com/wiki/index.php/Skeinforge#Tutorials
  39. Skeinforge tagged pages on thingiverse can be searched for at:
  40. http://www.thingiverse.com/search?cx=015525747728168968820%3Arqnsgx1xxcw&cof=FORID%3A9&ie=UTF-8&q=skeinforge&sa=Search&siteurl=www.thingiverse.com%2F#944
  41. ===Fabrication===
  42. 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:
  43. http://reprap.org/bin/view/Main/ArduinoSend
  44. Another way is to use an EMC2 or similar computer controlled milling machine, as described in the "ECM2 based repstrap" forum thread at:
  45. http://forums.reprap.org/read.php?1,12143
  46. using the M-Apps package, which is at:
  47. http://forums.reprap.org/file.php?1,file=772
  48. Another way is to use Zach's ReplicatorG at:
  49. http://replicat.org/
  50. There is also an older Processing script at:
  51. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/hoeken/arduino/GCode_Host/
  52. Yet another way is to use the reprap host, written in Java, to load and print gcode:
  53. http://dev.www.reprap.org/bin/view/Main/DriverSoftware#Load_GCode
  54. For jogging, the Metalab group wrote their own exerciser, also in Processing:
  55. http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/users/metalab/processing/GCode_Exerciser/
  56. The Metalab group has descriptions of skeinforge in action and their adventures are described at:
  57. http://reprap.soup.io/
  58. There is a board about printing issues at:
  59. http://www.bitsfrombytes.com/fora/user/index.php?board=5.0
  60. You can buy the Rapman (an improved Darwin) from Bits from Bytes at:
  61. http://www.bitsfrombytes.com/
  62. You can buy the Makerbot from Makerbot Industries at:
  63. http://www.makerbot.com/
  64. ===File Formats===
  65. An explanation of the gcodes is at:
  66. http://reprap.org/bin/view/Main/Arduino_GCode_Interpreter
  67. and at:
  68. http://reprap.org/bin/view/Main/MCodeReference
  69. A gode example is at:
  70. http://forums.reprap.org/file.php?12,file=565
  71. 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.
  72. The Scalable Vector Graphics file produced by vectorwrite can be opened by an SVG viewer or an SVG capable browser like Mozilla:
  73. http://www.mozilla.com/firefox/
  74. A good triangle surface format is the GNU Triangulated Surface format, which is supported by Mesh Viewer and described at:
  75. http://gts.sourceforge.net/reference/gts-surfaces.html#GTS-SURFACE-WRITE
  76. You can export GTS files from Art of Illusion with the Export GNU Triangulated Surface.bsh script in the Art of Illusion Scripts folder.
  77. STL is an inferior triangle surface format, described at:
  78. http://en.wikipedia.org/wiki/STL_(file_format)
  79. 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.
  80. ===Getting Skeinforge===
  81. The latest version is at:
  82. http://members.axion.net/~enrique/reprap_python_beanshell.zip
  83. a sometimes out of date version is in the last reprap_python_beanshell.zip attachment in the last post of the Fabmetheus blog at:
  84. http://fabmetheus.blogspot.com/
  85. another sometimes out of date version is at:
  86. https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/reprap/miscellaneous/python-beanshell-scripts/
  87. ===Getting Started===
  88. For skeinforge to run, install python 2.x on your machine, which is available from:
  89. http://www.python.org/download/
  90. 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:
  91. http://www.tcl.tk/software/tcltk/
  92. If you want python and Tkinter together on MacOS, you can try:
  93. http://www.astro.washington.edu/users/rowen/ROPackage/Overview.html
  94. 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:
  95. http://www.activestate.com/Products/activepython/feature_list.mhtml
  96. The computation intensive python modules will use psyco if it is available and run about twice as fast. Psyco is described at:
  97. http://psyco.sourceforge.net/index.html
  98. The psyco download page is:
  99. http://psyco.sourceforge.net/download.html
  100. 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:
  101. http://members.axion.net/~enrique/Export%20GNU%20Triangulated%20Surface.bsh
  102. 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:
  103. > python skeinforge.py
  104. 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'.
  105. Or you can turn files into gcode by adding the file name, for example:
  106. > python skeinforge.py Screw Holder Bottom.stl
  107. ===License===
  108. GNU Affero General Public License
  109. http://www.gnu.org/licenses/agpl.html
  110. ===Motto===
  111. I may be slow, but I get there in the end.
  112. ===Troubleshooting===
  113. If there's a bug, try downloading the very latest version because skeinforge is often updated without an announcement. The very latest version is at:
  114. http://members.axion.net/~enrique/reprap_python_beanshell.zip
  115. If there is still a bug, then first prepare the following files:
  116. 1. stl file
  117. 2. pictures explaining the problem
  118. 3. your settings (pack the whole .skeinforge directory with all your settings)
  119. 4. alterations folder, if you have any active alterations files
  120. Then zip all the files.
  121. 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.
  122. 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.
  123. 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.
  124. Comments and suggestions are welcome, however, I won't reply unless you are a contributor. Likewise, 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:
  125. http://dev.forums.reprap.org/read.php?12,27562
  126. You could also contribute articles to demozendium on any topic:
  127. http://fabmetheus.crsndoo.com/wiki/index.php/Main_Page
  128. If you contribute in a significant way to another open source project, I will consider that also.
  129. When I answered everyone's questions, eventually I received more questions than I had time to answer, so now I only answer questions from contributors.
  130. I reserve the right to make any correspondence public. Do not send me any correspondence marked confidential. If you do I will delete it.
  131. ==Examples==
  132. 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.
  133. > python skeinforge.py
  134. This brings up the dialog, after clicking 'Skeinforge', the following is printed:
  135. The exported file is saved as Screw Holder_export.gcode
  136. > python skeinforge.py Screw Holder.stl
  137. The exported file is saved as Screw Holder_export.gcode
  138. To run only fill for example, type in the craft_plugins folder which fill is in:
  139. > python fill.py
  140. """
  141. from __future__ import absolute_import
  142. import __init__
  143. from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
  144. from fabmetheus_utilities import archive
  145. from fabmetheus_utilities import settings
  146. from optparse import OptionParser
  147. from skeinforge_application.skeinforge_utilities import skeinforge_craft
  148. from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
  149. from skeinforge_application.skeinforge_utilities import skeinforge_profile
  150. import sys
  151. # double circle top infill in skin
  152. # weird missing line on second layer of interfaceRaft
  153. # circle is average radius in circle, cylinder, drill, extrude
  154. # infuse _extrusion
  155. # base xmlelement off xmlatom
  156. # cutting ahmet
  157. # smooth http://hydraraptor.blogspot.com/2010/12/frequency-limit.html _extrusion
  158. # think about changing getOverlapRatio(loop, pointDictionary) < 0.2 to 0.51
  159. # change topOverBottom in linearbearingexample to pegAngle
  160. # add links download manual svg_writer, add left right arrow keys to layer
  161. # change thickness to height in gear xml
  162. # documentation Retract When Crossing
  163. # document announce convex, http://www.thingiverse.com/thing:7652
  164. # document clairvoyance, announcement
  165. # maybe in svgReader if loop intersection with previous union else add
  166. # think about http://code.google.com/p/skeinarchiver/ and/or undo
  167. #
  168. # unimportant
  169. # minor outline problem when an end path goes through a path, like in the letter A
  170. # view profile 1 mm thickness
  171. #
  172. # raftPerimeter outset by maximum thickness
  173. # When opening a file for craft I wondered if there is an option to set the file type to .stl as it currently defaults to .xml
  174. # scrollbar/width problem when starting with narrow view like help/meta/profile
  175. # check inset loop for intersection with rotatedLoopLayer.loops
  176. # maybe make vectorwrite prominent, not skeiniso, probably not because it doesn't work on Mac
  177. # move more __file__
  178. # close, getPillarByLoopLists, addConcave, polymorph original graph section, loop, add step object, add continuous object
  179. # hollow top
  180. # chamber: heated bed off at a layer http://blog.makerbot.com/2011/03/17/if-you-cant-stand-the-heat/
  181. # packingDensity or density in grid - probably just density
  182. # derivations for shapes
  183. # think about rectangular getVector3RemoveByPre..
  184. # links in layerTemplate
  185. # del previous, add begin & end if far get actual path
  186. # linearbearingexample 15 x 1 x 2, linearbearingcage
  187. # add date time 11.01.02|12:08
  188. # polling
  189. # connectionfrom, to, connect, xaxis
  190. # lathe, transform normal in getRemaining, getConnection
  191. # getConnection of some kind like getConnectionVertexes, getConnection
  192. # xml_creation
  193. # voronoi average location intersection looped inset intercircles
  194. # 'fileName, text, repository' commandLineInterface
  195. # delete: text = text.replace(('\nName %sValue\n' % globalSpreadsheetSeparator), ('\n_Name %sValue\n' % globalSpreadsheetSeparator))
  196. #
  197. #
  198. # multiply to table + boundary bedBound bedWidth bedHeight bedFile.csv
  199. # getNormal, getIsFlat?
  200. # info statistics, procedures, xml if any
  201. # test solid arguments
  202. # combine xmlelement with csvelement using example.csv & geometry.csv, csv _format, _column, _row, _text
  203. # pixel, voxel, surfaxel/boxel, lattice, mesh
  204. # probably not replace getOverlapRatio with getOverlap if getOverlapRatio is never small, always 0.0
  205. # mesh. for cube, then cyliner, then sphere after lathe
  206. # dimension extrude diameter, density
  207. # thermistor lookup table
  208. # add overview link to crnsdoo index and svg page
  209. # stretch add back addAlong
  210. # import, write, copy examples
  211. # maybe remove default warnings from scale, rotate, translate, transform
  212. # easy helix
  213. # write tool; maybe write one deep
  214. #
  215. #
  216. # tube
  217. # rotor
  218. # coin
  219. # demozendium privacy policy, maybe thumbnail logo
  220. # pymethe
  221. # test translate
  222. # full lathe
  223. # pyramid
  224. # round extrusion ?, fillet
  225. # make html statistics, move statistics to folder
  226. # manipulate solid, maybe manipulate around elements
  227. # boolean loop corner outset
  228. # mechaslab advanced drainage, shingles
  229. # dovetail
  230. # maybe not getNewObject, getNew, addToBoolean
  231. # work out close and radius
  232. # maybe try to get rid of comment if possible
  233. # maybe have add function as well as append for list and string
  234. # maybe move and give geometryOutput to cube, cylinder, sphere
  235. #
  236. # comb -> maybe add back running jump look at outside loops only for jump, find closest points, find slightly away inside points, link
  237. # global simplify pathBetween
  238. # comb documentation
  239. #
  240. # maybe move widen before bottom
  241. # maybe add 1 to max layer input to iso in layer_template.svg
  242. # maybe save all generated_files option
  243. # table to dictionary
  244. # check for last existing then remove unneeded fill code (getLastExistingFillLoops) from euclidean
  245. # remove cool set at end of layer
  246. # add fan on when hot in chamber
  247. # maybe measuring rod
  248. # getLayerThickness from xml
  249. # maybe center for xy plane
  250. # remove comments from clip, bend
  251. # winding into coiling, coil into wind & weave
  252. # later, precision
  253. # documentation
  254. # http://wiki.makerbot.com/configuring-skeinforge
  255. #
  256. #
  257. # remove index from CircleIntersection remove ahead or behind from CircleIntersection _speed
  258. # cache surroundingCarves _speed
  259. # probably not speed up CircleIntersection by performing isWithinCircles before creation _speed
  260. # pixelSet instead of pixelTable for arounds _speed
  261. #
  262. #
  263. # add hook _extrusion
  264. # integral thin width _extrusion
  265. # layer color, for multilayer start http://reprap.org/pub/Main/MultipleMaterialsFiles/legend.xml _extrusion
  266. # maybe double height shells option _extrusion
  267. # maybe raft triple layer base, middle interface with hot loop or ties
  268. # somehow, add pattern to outside, http://blog.makerbot.com/2010/09/03/lampshades/
  269. # implement acceleration & collinear removal in penultimate viewers _extrusion
  270. #
  271. # rename skeinforge_profile.addListsToCraftTypeRepository to skeinforge_profile.addToCraftTypeRepository after apron
  272. # basic tool
  273. # arch, ceiling
  274. # meta setting, rename setting _setting
  275. # add polish, has perimeter, has cut first layer (False)
  276. # probably not set addedLocation in distanceFeedRate after arc move
  277. # maybe horizontal bridging and/or check to see if the ends are standing on anything
  278. # thin self? check when removing intersecting paths in inset
  279. # maybe later remove isPerimeterPathInSurroundLoops, once there are no weird fill bugs, also change getHorizontalSegmentListsFromLoopLists
  280. # save all analyze viewers of the same name except itself, update help menu self.wikiManualPrimary.setUpdateFunction
  281. # check alterations folder first, if there is something copy it to the home directory, if not check the home directory
  282. # set temperature in temperature
  283. # add links to demozendium in help
  284. # maybe add hop only if long option
  285. #
  286. #
  287. #
  288. # help primary menu item refresh
  289. # add plugin help menu, add craft below menu
  290. # give option of saving when switching profiles
  291. # xml & svg more forgiving, svg make defaults for extrusionHeight
  292. # option of surrounding lines in display
  293. # maybe add connecting line in display line
  294. # maybe check inset loops to see if they are smaller, but this would be slow
  295. # maybe status bar
  296. # maybe measurement ruler mouse tool
  297. # search rss from blogs, add search links for common materials, combine created on or progress bar with searchable help
  298. # boundaries, center radius z bottom top, alterations file, circular or rectangular, polygon, put cool minimum radius orbits within boundaries, <bounds> bound.. </bounds>
  299. # move & rotate model
  300. # possible jitter bug http://cpwebste.blogspot.com/2010/04/hydras-first-print.html
  301. # trial, meta in a grid settings
  302. # maybe interpret svg_convex_mesh
  303. #laminate tool head
  304. #maybe use 5x5 radius search in circle node
  305. #maybe add layer updates in behold, skeinlayer and maybe others
  306. #lathe winding, extrusion and cutting; synonym for rotation or turning, loop angle
  307. # maybe split into source code and documentation sections
  308. # transform plugins, start with sarrus http://www.thingiverse.com/thing:1425
  309. # maybe make setting backups
  310. # maybe settings in gcode or saved versions
  311. # move skeinforge_utilities to fabmetheus_utilities
  312. # maybe lathe cutting
  313. # maybe lathe extrusion
  314. # maybe lathe millng
  315. # maybe lathe winding & weaving
  316. #
  317. #
  318. #
  319. # pick and place
  320. # search items, search links, choice entry field
  321. # svg triangle mesh, svg polygon mesh
  322. # simulate
  323. #transform
  324. # juricator
  325. # probably not run along sparse infill to avoid stops
  326. #custom inclined plane, inclined plane from model, screw, fillet travel as well maybe
  327. # probably not stretch single isLoop
  328. #maybe much afterwards make congajure multistep view
  329. #maybe stripe although model colors alone can handle it
  330. #stretch fiber around shape, maybe modify winding for asymmetric shapes
  331. #multiple heads around edge
  332. #maybe add rarely used tool option
  333. #angle shape for overhang extrusions
  334. #maybe m111? countdown
  335. #first time tool tip
  336. #individual tool tip to place in text
  337. # maybe try to simplify raft layer start
  338. # maybe make temp directory
  339. # maybe carve aoi xml testing and check xml gcode
  340. # maybe cross hatch support polishing???
  341. # maybe print svg view from current layer or zero layer in single view
  342. # maybe check if tower is picking the nearest island
  343. # maybe combine skein classes in fillet
  344. # maybe isometric svg option
  345. #Manual
  346. #10,990
  347. #11,1776,786
  348. #12,3304,1528
  349. #1,4960,1656
  350. #2, 7077,2117
  351. #3, 9598,2521
  352. #4 12014,2305
  353. #5 14319,2536
  354. #6 16855,3226
  355. #7 20081, 2189
  356. #8 22270, 2625
  357. #9 24895, 2967, 98
  358. #10 27862, 3433, 110
  359. #11 31295, 3327
  360. #12 34622
  361. #85 jan7, 86jan11, 87 jan13, 88 jan15, 91 jan21, 92 jan23, 95 jan30, 98 feb6
  362. #make one piece electromagnet spool
  363. #stepper rotor with ceramic disk magnet in middle, electromagnet with long thin spool line?
  364. #stepper motor
  365. #make plastic coated thread in vat with pulley
  366. #tensile stuart platform
  367. #kayak
  368. #gear vacuum pump
  369. #gear turbine
  370. #heat engine
  371. #solar power
  372. #sailboat
  373. #yacht
  374. #house
  375. #condo with reflected gardens in between buildings
  376. #medical equipment
  377. #cell counter, etc..
  378. #pipe clamp lathe
  379. # square tube driller & cutter
  380. # archihedrongagglevoteindexium
  381. # outline images
  382. # 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
  383. # when loading a file, we should have a preview of the part and orientation in space
  384. # 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
  385. # third, a routine to detect the largest face and orient the part accordingly. Mat http://reprap.kumy.net/
  386. # concept, three perpendicular slices to get display spheres
  387. # extend lines around short segment after cross hatched boolean
  388. # concept, donation, postponement, rotate ad network, cached search options
  389. # concept, local ad server, every time the program runs it changes the iamge which all the documentation points to from a pool of ads
  390. # 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
  391. # 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
  392. # concept, diamond cross section loops
  393. # concept, in file, store polygon mesh and centers
  394. # concept, display spheres or polygons would have original triangle for work plane
  395. # .. then again no point with slices
  396. # concept, filled slices, about 2 mm thick
  397. # concept, rgb color triangle switch to get inside color, color golden ratio on 5:11 slope with a modulo 3 face
  398. # concept, interlaced bricks at corners ( length proportional to corner angle )
  399. # concept, new links to archi, import links to archi and adds skeinforge tool menu item, back on skeinforge named execute tool is added
  400. # concept, trnsnt
  401. # concept, indexium expand condense remove, single text, pymetheus
  402. # concept, inscribed key silencer
  403. # concept, spreadsheet to python and/or javascript
  404. # concept, range voting for posters, informative, complainer, funny, insightful, rude, spammer, literacy, troll?
  405. # concept, intermittent cloud with multiple hash functions
  406. __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
  407. __credits__ = """
  408. Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
  409. Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
  410. Greenarrow <http://forums.reprap.org/profile.php?12,81>
  411. Ian England <http://forums.reprap.org/profile.php?12,192>
  412. John Gilmore <http://forums.reprap.org/profile.php?12,364>
  413. Jonwise <http://forums.reprap.org/profile.php?12,716>
  414. Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
  415. Michael Duffin <http://forums.reprap.org/profile.php?12,930>
  416. Marius Kintel <http://reprap.soup.io/>
  417. Nophead <http://www.blogger.com/profile/12801535866788103677>
  418. PJR <http://forums.reprap.org/profile.php?12,757>
  419. Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
  420. Wade <http://forums.reprap.org/profile.php?12,489>
  421. Xsainnz <http://forums.reprap.org/profile.php?12,563>
  422. Zach Hoeken <http://blog.zachhoeken.com/>
  423. Organizations:
  424. Art of Illusion <http://www.artofillusion.org/>"""
  425. __date__ = '$Date: 2008/02/05 $'
  426. __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
  427. def addToProfileMenu(profileSelection, profileType, repository):
  428. """Add a profile menu."""
  429. pluginFileNames = skeinforge_profile.getPluginFileNames()
  430. craftTypeName = skeinforge_profile.getCraftTypeName()
  431. pluginModule = skeinforge_profile.getCraftTypePluginModule()
  432. profilePluginSettings = settings.getReadRepository(pluginModule.getNewRepository())
  433. for pluginFileName in pluginFileNames:
  434. skeinforge_profile.ProfileTypeMenuRadio().getFromMenuButtonDisplay(profileType, pluginFileName, repository, craftTypeName == pluginFileName)
  435. for profileName in profilePluginSettings.profileList.value:
  436. skeinforge_profile.ProfileSelectionMenuRadio().getFromMenuButtonDisplay(profileSelection, profileName, repository, profileName == profilePluginSettings.profileListbox.value)
  437. def getNewRepository():
  438. """Get new repository."""
  439. return SkeinforgeRepository()
  440. def getPluginFileNames():
  441. """Get skeinforge plugin fileNames."""
  442. return archive.getPluginFileNamesFromDirectoryPath(archive.getSkeinforgePluginsPath())
  443. def getRadioPluginsAddPluginGroupFrame(directoryPath, importantFileNames, names, repository):
  444. """Get the radio plugins and add the plugin frame."""
  445. repository.pluginGroupFrame = settings.PluginGroupFrame()
  446. radioPlugins = []
  447. for name in names:
  448. radioPlugin = settings.RadioPlugin().getFromRadio(name in importantFileNames, repository.pluginGroupFrame.latentStringVar, name, repository, name == importantFileNames[0])
  449. radioPlugin.updateFunction = repository.pluginGroupFrame.update
  450. radioPlugins.append( radioPlugin )
  451. defaultRadioButton = settings.getSelectedRadioPlugin(importantFileNames + [radioPlugins[0].name], radioPlugins)
  452. repository.pluginGroupFrame.getFromPath(defaultRadioButton, directoryPath, repository)
  453. return radioPlugins
  454. def writeOutput(fileName):
  455. """Craft a file, display dialog."""
  456. repository = getNewRepository()
  457. repository.fileNameInput.value = fileName
  458. repository.execute()
  459. settings.startMainLoopFromConstructor(repository)
  460. class SkeinforgeRepository:
  461. """A class to handle the skeinforge settings."""
  462. def __init__(self):
  463. """Set the default settings, execute title & settings fileName."""
  464. skeinforge_profile.addListsToCraftTypeRepository('skeinforge_application.skeinforge.html', self)
  465. self.fileNameInput = settings.FileNameInput().getFromFileName( fabmetheus_interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '')
  466. self.profileType = settings.MenuButtonDisplay().getFromName('Profile Type: ', self )
  467. self.profileSelection = settings.MenuButtonDisplay().getFromName('Profile Selection: ', self)
  468. addToProfileMenu( self.profileSelection, self.profileType, self )
  469. settings.LabelDisplay().getFromName('Search:', self )
  470. reprapSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_reprap.html', 'Reprap', self)
  471. skeinforgeSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_skeinforge.html', 'Skeinforge', self )
  472. skeinforgeSearch.column += 2
  473. webSearch = settings.HelpPage().getFromNameAfterHTTP('members.axion.net/~enrique/search_web.html', 'Web', self)
  474. webSearch.column += 4
  475. versionText = archive.getFileText( archive.getVersionFileName() )
  476. self.version = settings.LabelDisplay().getFromName('Version: ' + versionText, self)
  477. settings.LabelDisplay().getFromName('', self)
  478. importantFileNames = ['craft', 'profile']
  479. getRadioPluginsAddPluginGroupFrame(archive.getSkeinforgePluginsPath(), importantFileNames, getPluginFileNames(), self)
  480. self.executeTitle = 'Skeinforge'
  481. self.repositoryDialog = None
  482. def execute(self):
  483. """Skeinforge button has been clicked."""
  484. fileNames = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode(self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled)
  485. for fileName in fileNames:
  486. skeinforge_craft.writeOutput(fileName)
  487. def save(self):
  488. """Profile has been saved and profile menu should be updated."""
  489. self.profileType.removeMenus()
  490. self.profileSelection.removeMenus()
  491. addToProfileMenu(self.profileSelection, self.profileType, self)
  492. self.profileType.addRadiosToDialog(self.repositoryDialog)
  493. self.profileSelection.addRadiosToDialog(self.repositoryDialog)
  494. def main():
  495. """Display the skeinforge dialog."""
  496. parser = OptionParser()
  497. parser.add_option(
  498. '-p', '--prefdir', help='set path to preference directory', action='store', type='string', dest='preferencesDirectory')
  499. parser.add_option(
  500. '-s', '--start', help='set start file to use', action='store', type='string', dest='startFile')
  501. parser.add_option(
  502. '-e', '--end', help='set end file to use', action='store', type='string', dest='endFile')
  503. parser.add_option(
  504. '-o', '--option', help='set an individual option in the format "module:preference=value"',
  505. action='append', type='string', dest='preferences')
  506. (options, args) = parser.parse_args()
  507. if options.preferencesDirectory:
  508. archive.globalTemporarySettingsPath = options.preferencesDirectory
  509. if options.preferences:
  510. for prefSpec in options.preferences:
  511. (moduleName, prefSpec) = prefSpec.split(':', 1)
  512. (prefName, valueName) = prefSpec.split('=', 1)
  513. settings.addPreferenceOverride(moduleName, prefName, valueName)
  514. sys.argv = [sys.argv[0]] + args
  515. if len( args ) > 0:
  516. writeOutput( ' '.join(args) )
  517. else:
  518. settings.startMainLoopFromConstructor(getNewRepository())
  519. if __name__ == '__main__':
  520. main()