PageRenderTime 888ms CodeModel.GetById 33ms RepoModel.GetById 10ms app.codeStats 0ms

/sfact.py

https://github.com/blujule4218/SFACT
Python | 637 lines | 308 code | 43 blank | 286 comment | 36 complexity | 621d971bd14608e352464fa288913ab0 MD5 | raw file
Possible License(s): AGPL-3.0
  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 euclidean
  146. from fabmetheus_utilities import gcodec
  147. from fabmetheus_utilities import settings
  148. from optparse import OptionParser
  149. from skeinforge_application.skeinforge_utilities import skeinforge_craft
  150. from skeinforge_application.skeinforge_plugins.analyze_plugins import skeinlayer
  151. from skeinforge_application.skeinforge_utilities import skeinforge_polyfile
  152. from skeinforge_application.skeinforge_utilities import skeinforge_profile
  153. import os
  154. import sys
  155. # attributeDictionary, write, getTextContent, comment, pcdata, idDictionary.., importName getImportChain, document, rootElement
  156. # cool travel bug? getLayerTimeActive multiplier = active / (remainder + active) http://forums.reprap.org/read.php?154,91413
  157. # double circle top infill in skin & above layer, should clip before getAroundsFromPath(
  158. # circle is average radius in circle, cylinder, drill, extrude
  159. # infuse _extrusion
  160. # cutting ahmet
  161. # smooth http://hydraraptor.blogspot.com/2010/12/frequency-limit.html _extrusion
  162. # think about changing getOverlapRatio(loop, pointDictionary) < 0.2 to 0.51
  163. # change topOverBottom in linearbearingexample to pegAngle
  164. # add links download manual svg_writer, add left right arrow keys to layer
  165. # change thickness to face width in gear xml
  166. # documentation Retract When Crossing
  167. # document announce skirt convex
  168. # announcement clairvoyance, synopsis, export http://garyhodgson.com/reprap/2011/06/hacking-skeinforge-export-module/
  169. # maybe in svgReader if loop intersection with previous union else add
  170. # think about http://code.google.com/p/skeinarchiver/ and/or undo
  171. #
  172. # unimportant
  173. # minor outline problem when an end path goes through a path, like in the letter A
  174. # view profile 1 mm thickness
  175. #
  176. # raftPerimeter outset by maximum thickness
  177. # xmlparser to xmldocument, xmlelement of xml dom, originally 563 http://stackoverflow.com/questions/1971186/how-to-set-elements-id-in-pythons-xml-dom-minidom
  178. # 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
  179. # scrollbar/width problem when starting with narrow view like help/meta/profile
  180. # check inset loop for intersection with rotatedLoopLayer.loops
  181. # maybe make vectorwrite prominent, not skeiniso, probably not because it doesn't work on Mac
  182. # move more __file__
  183. # close, getPillarByLoopLists, addConcave, polymorph original graph section, loop, add step object, add continuous object
  184. # hollow top
  185. # chamber: heated bed off at a layer http://blog.makerbot.com/2011/03/17/if-you-cant-stand-the-heat/
  186. # packingDensity or density in grid - probably just density
  187. # derivations for shapes
  188. # think about rectangular getVector3RemoveByPre..
  189. # links in layerTemplate
  190. # del previous, add begin & end if far get actual path
  191. # linearbearingexample 15 x 1 x 2, linearbearingcage
  192. # add date time 11.01.02|12:08
  193. # polling
  194. # connectionfrom, to, connect, xaxis
  195. # lathe, transform normal in getRemaining, getConnection
  196. # getConnection of some kind like getConnectionVertexes, getConnection
  197. # xml_creation
  198. # voronoi average location intersection looped inset intercircles
  199. # 'fileName, text, repository' commandLineInterface
  200. # delete: text = text.replace(('\nName %sValue\n' % globalSpreadsheetSeparator), ('\n_Name %sValue\n' % globalSpreadsheetSeparator))
  201. #
  202. #
  203. # multiply to table + boundary bedBound bedWidth bedHeight bedFile.csv
  204. # getNormal, getIsFlat?
  205. # info statistics, procedures, xml if any
  206. # test solid arguments
  207. # combine xmlelement with csvelement using example.csv & geometry.csv, csv _format, _column, _row, _text
  208. # pixel, voxel, surfaxel/boxel, lattice, mesh
  209. # probably not replace getOverlapRatio with getOverlap if getOverlapRatio is never small, always 0.0
  210. # mesh. for cube, then cyliner, then sphere after lathe
  211. # dimension extrude diameter, density
  212. # thermistor lookup table
  213. # add overview link to crnsdoo index and svg page
  214. # stretch add back addAlong
  215. # import, write, copy examples
  216. # maybe remove default warnings from scale, rotate, translate, transform
  217. # easy helix
  218. # write tool; maybe write one deep
  219. #
  220. #
  221. # tube
  222. # rotor
  223. # coin
  224. # demozendium privacy policy, maybe thumbnail logo
  225. # pymethe
  226. # test translate
  227. # full lathe
  228. # pyramid
  229. # round extrusion ?, fillet
  230. # make html statistics, move statistics to folder
  231. # manipulate solid, maybe manipulate around elements
  232. # boolean loop corner outset
  233. # mechaslab advanced drainage, shingles
  234. # dovetail
  235. # maybe not getNewObject, getNew, addToBoolean
  236. # work out close and radius
  237. # maybe try to get rid of comment if possible
  238. # maybe have add function as well as append for list and string
  239. # maybe move and give geometryOutput to cube, cylinder, sphere
  240. #
  241. # comb -> maybe add back running jump look at outside loops only for jump, find closest points, find slightly away inside points, link
  242. # global simplify pathBetween
  243. # comb documentation
  244. #
  245. # maybe move widen before bottom
  246. # maybe add 1 to max layer input to iso in layer_template.svg
  247. # maybe save all generated_files option
  248. # table to dictionary
  249. # check for last existing then remove unneeded fill code (getLastExistingFillLoops) from euclidean
  250. # remove cool set at end of layer
  251. # add fan on when hot in chamber
  252. # maybe measuring rod
  253. # getLayerThickness from xml
  254. # maybe center for xy plane
  255. # remove comments from clip, bend
  256. # winding into coiling, coil into wind & weave
  257. # later, precision
  258. # documentation
  259. # http://wiki.makerbot.com/configuring-skeinforge
  260. #
  261. #
  262. # remove index from CircleIntersection remove ahead or behind from CircleIntersection _speed
  263. # cache surroundingCarves _speed
  264. # probably not speed up CircleIntersection by performing isWithinCircles before creation _speed
  265. # pixelSet instead of pixelTable for arounds _speed
  266. #
  267. #
  268. # add hook _extrusion
  269. # integral thin width _extrusion
  270. # layer color, for multilayer start http://reprap.org/pub/Main/MultipleMaterialsFiles/legend.xml _extrusion
  271. # maybe double height shells option _extrusion
  272. # maybe raft triple layer base, middle interface with hot loop or ties
  273. # somehow, add pattern to outside, http://blog.makerbot.com/2010/09/03/lampshades/
  274. # implement acceleration & collinear removal in penultimate viewers _extrusion
  275. #
  276. # rename skeinforge_profile.addListsToCraftTypeRepository to skeinforge_profile.addToCraftTypeRepository after apron
  277. # basic tool
  278. # arch, ceiling
  279. # meta setting, rename setting _setting
  280. # add polish, has perimeter, has cut first layer (False)
  281. # probably not set addedLocation in distanceFeedRate after arc move
  282. # maybe horizontal bridging and/or check to see if the ends are standing on anything
  283. # thin self? check when removing intersecting paths in inset
  284. # maybe later remove isPerimeterPathInSurroundLoops, once there are no weird fill bugs, also change getHorizontalSegmentListsFromLoopLists
  285. # save all analyze viewers of the same name except itself, update help menu self.wikiManualPrimary.setUpdateFunction
  286. # check alterations folder first, if there is something copy it to the home directory, if not check the home directory
  287. # set temperature in temperature
  288. # add links to demozendium in help
  289. # maybe add hop only if long option
  290. #
  291. #
  292. #
  293. # help primary menu item refresh
  294. # add plugin help menu, add craft below menu
  295. # give option of saving when switching profiles
  296. # xml & svg more forgiving, svg make defaults for layerHeight
  297. # option of surrounding lines in display
  298. # maybe add connecting line in display line
  299. # maybe check inset loops to see if they are smaller, but this would be slow
  300. # maybe status bar
  301. # maybe measurement ruler mouse tool
  302. # search rss from blogs, add search links for common materials, combine created on or progress bar with searchable help
  303. # boundaries, center radius z bottom top, alterations file, circular or rectangular, polygon, put cool minimum radius orbits within boundaries, <bounds> bound.. </bounds>
  304. # move & rotate model
  305. # possible jitter bug http://cpwebste.blogspot.com/2010/04/hydras-first-print.html
  306. # trial, meta in a grid settings
  307. # maybe interpret svg_convex_mesh
  308. #laminate tool head
  309. #maybe use 5x5 radius search in circle node
  310. #maybe add layer updates in behold, skeinlayer and maybe others
  311. #lathe winding, extrusion and cutting; synonym for rotation or turning, loop angle
  312. # maybe split into source code and documentation sections
  313. # transform plugins, start with sarrus http://www.thingiverse.com/thing:1425
  314. # maybe make setting backups
  315. # maybe settings in gcode or saved versions
  316. # move skeinforge_utilities to fabmetheus_utilities
  317. # maybe lathe cutting
  318. # maybe lathe extrusion
  319. # maybe lathe millng
  320. # maybe lathe winding & weaving
  321. #
  322. #
  323. #
  324. # pick and place
  325. # search items, search links, choice entry field
  326. # svg triangle mesh, svg polygon mesh
  327. # simulate
  328. #transform
  329. # juricator
  330. # probably not run along sparse infill to avoid stops
  331. #custom inclined plane, inclined plane from model, screw, fillet travel as well maybe
  332. # probably not stretch single isLoop
  333. #maybe much afterwards make congajure multistep view
  334. #maybe stripe although model colors alone can handle it
  335. #stretch fiber around shape, maybe modify winding for asymmetric shapes
  336. #multiple heads around edge
  337. #maybe add rarely used tool option
  338. #angle shape for overhang extrusions
  339. #maybe m111? countdown
  340. #first time tool tip
  341. #individual tool tip to place in text
  342. # maybe try to simplify raft layer start
  343. # maybe make temp directory
  344. # maybe carve aoi xml testing and check xml gcode
  345. # maybe cross hatch support polishing???
  346. # maybe print svg view from current layer or zero layer in single view
  347. # maybe check if tower is picking the nearest island
  348. # maybe combine skein classes in fillet
  349. # maybe isometric svg option
  350. #Manual
  351. #10,990
  352. #11,1776,786
  353. #12,3304,1528
  354. #1,4960,1656
  355. #2, 7077,2117
  356. #3, 9598,2521
  357. #4 12014,2305
  358. #5 14319,2536
  359. #6 16855,3226
  360. #7 20081, 2189
  361. #8 22270, 2625
  362. #9 24895, 2967, 98
  363. #10 27862, 3433, 110
  364. #11 31295, 3327
  365. #12 34622
  366. #85 jan7, 86jan11, 87 jan13, 88 jan15, 91 jan21, 92 jan23, 95 jan30, 98 feb6
  367. #make one piece electromagnet spool
  368. #stepper rotor with ceramic disk magnet in middle, electromagnet with long thin spool line?
  369. #stepper motor
  370. #make plastic coated thread in vat with pulley
  371. #tensile stuart platform
  372. #kayak
  373. #gear vacuum pump
  374. #gear turbine
  375. #heat engine
  376. #solar power
  377. #sailboat
  378. #yacht
  379. #house
  380. #condo with reflected gardens in between buildings
  381. #medical equipment
  382. #cell counter, etc..
  383. #pipe clamp lathe
  384. # square tube driller & cutter
  385. # archihedrongagglevoteindexium
  386. # outline images
  387. # 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
  388. # when loading a file, we should have a preview of the part and orientation in space
  389. # 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
  390. # third, a routine to detect the largest face and orient the part accordingly. Mat http://reprap.kumy.net/
  391. # concept, three perpendicular slices to get display spheres
  392. # extend lines around short segment after cross hatched boolean
  393. # concept, donation, postponement, rotate ad network, cached search options
  394. # concept, local ad server, every time the program runs it changes the iamge which all the documentation points to from a pool of ads
  395. # 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
  396. # 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
  397. # concept, diamond cross section loops
  398. # concept, in file, store polygon mesh and centers
  399. # concept, display spheres or polygons would have original triangle for work plane
  400. # .. then again no point with slices
  401. # concept, filled slices, about 2 mm thick
  402. # concept, rgb color triangle switch to get inside color, color golden ratio on 5:11 slope with a modulo 3 face
  403. # concept, interlaced bricks at corners ( length proportional to corner angle )
  404. # concept, new links to archi, import links to archi and adds skeinforge tool menu item, back on skeinforge named execute tool is added
  405. # concept, trnsnt
  406. # concept, indexium expand condense remove, single text, pymetheus
  407. # concept, inscribed key silencer
  408. # concept, spreadsheet to python and/or javascript
  409. # concept, range voting for posters, informative, complainer, funny, insightful, rude, spammer, literacy, troll?
  410. # concept, intermittent cloud with multiple hash functions
  411. __author__ = 'Enrique Perez (perez_enrique@yahoo.com) modifed as SFACT by Ahmet Cem Turan (ahmetcemturan@gmail.com)'
  412. __credits__ = """
  413. Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
  414. Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
  415. Greenarrow <http://forums.reprap.org/profile.php?12,81>
  416. Ian England <http://forums.reprap.org/profile.php?12,192>
  417. John Gilmore <http://forums.reprap.org/profile.php?12,364>
  418. Jonwise <http://forums.reprap.org/profile.php?12,716>
  419. Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
  420. Michael Duffin <http://forums.reprap.org/profile.php?12,930>
  421. Marius Kintel <http://reprap.soup.io/>
  422. Nophead <http://www.blogger.com/profile/12801535866788103677>
  423. PJR <http://forums.reprap.org/profile.php?12,757>
  424. Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
  425. Wade <http://forums.reprap.org/profile.php?12,489>
  426. Xsainnz <http://forums.reprap.org/profile.php?12,563>
  427. Zach Hoeken <http://blog.zachhoeken.com/>
  428. Organizations:
  429. Art of Illusion <http://www.artofillusion.org/>"""
  430. __date__ = '$Date: 2008/02/05 $'
  431. __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
  432. #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
  433. def addToProfileMenu(profileSelection, profileType, repository):
  434. 'Add a profile menu.'
  435. pluginFileNames = skeinforge_profile.getPluginFileNames()
  436. craftTypeName = skeinforge_profile.getCraftTypeName()
  437. pluginModule = skeinforge_profile.getCraftTypePluginModule()
  438. profilePluginSettings = settings.getReadRepository(pluginModule.getNewRepository())
  439. for pluginFileName in pluginFileNames:
  440. skeinforge_profile.ProfileTypeMenuRadio().getFromMenuButtonDisplay(profileType, pluginFileName, repository, craftTypeName == pluginFileName)
  441. for profileName in profilePluginSettings.profileList.value:
  442. skeinforge_profile.ProfileSelectionMenuRadio().getFromMenuButtonDisplay(profileSelection, profileName, repository, profileName == profilePluginSettings.profileListbox.value)
  443. def getNewRepository():
  444. 'Get new repository.'
  445. return SkeinforgeRepository()
  446. def getPluginFileNames():
  447. 'Get skeinforge plugin fileNames.'
  448. return archive.getPluginFileNamesFromDirectoryPath(archive.getSkeinforgePluginsPath())
  449. def getRadioPluginsAddPluginGroupFrame(directoryPath, importantFileNames, names, repository):
  450. 'Get the radio plugins and add the plugin frame.'
  451. repository.pluginGroupFrame = settings.PluginGroupFrame()
  452. radioPlugins = []
  453. for name in names:
  454. radioPlugin = settings.RadioPlugin().getFromRadio(name in importantFileNames, repository.pluginGroupFrame.latentStringVar, name, repository, name == importantFileNames[0])
  455. radioPlugin.updateFunction = repository.pluginGroupFrame.update
  456. radioPlugins.append( radioPlugin )
  457. defaultRadioButton = settings.getSelectedRadioPlugin(importantFileNames + [radioPlugins[0].name], radioPlugins)
  458. repository.pluginGroupFrame.getFromPath(defaultRadioButton, directoryPath, repository)
  459. return radioPlugins
  460. def writeOutput(fileName):
  461. 'Craft a file, display dialog.'
  462. repository = getNewRepository()
  463. repository.fileNameInput.value = fileName
  464. repository.execute()
  465. settings.startMainLoopFromConstructor(repository)
  466. class SkeinforgeRepository:
  467. 'A class to handle the skeinforge settings.'
  468. def __init__(self):
  469. 'Set the default settings, execute title & settings fileName.'
  470. skeinforge_profile.addListsToCraftTypeRepository('skeinforge_application.skeinforge.html', self)
  471. self.fileNameInput = settings.FileNameInput().getFromFileName( fabmetheus_interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File for Skeinforge', self, '')
  472. self.profileType = settings.MenuButtonDisplay().getFromName('Profile Type: ', self )
  473. self.profileSelection = settings.MenuButtonDisplay().getFromName('Profile Selection: ', self)
  474. addToProfileMenu( self.profileSelection, self.profileType, self )
  475. settings.LabelDisplay().getFromName('Search:', self )
  476. reprapSearch = settings.HelpPage().getFromNameAfterHTTP('github.com/ahmetcemturan/SFACT', 'SFACT Update', self)
  477. skeinforgeSearch = settings.HelpPage().getFromNameAfterHTTP('www.reprapfordummies.net/index.php/softwaresection/44-gcode-generators/49-sfact-homepage', 'SFACT Help', self )
  478. skeinforgeSearch.column += 6
  479. webSearch = settings.HelpPage().getFromNameAfterHTTP('www.reprap.org', 'Reprap', self)
  480. webSearch.column += 4
  481. versionText = archive.getFileText( archive.getVersionFileName() )
  482. self.version = settings.LabelDisplay().getFromName('Version: ' + versionText, self)
  483. settings.LabelDisplay().getFromName('', self)
  484. importantFileNames = ['craft', 'profile']
  485. getRadioPluginsAddPluginGroupFrame(archive.getSkeinforgePluginsPath(), importantFileNames, getPluginFileNames(), self)
  486. self.usePyPyforSlicing = settings.BooleanSetting().getFromValue('Slice with PyPy ', self, True )
  487. self.executeTitle = 'Skeinforge'
  488. def execute(self):
  489. 'Skeinforge button has been clicked.'
  490. fileNames = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode(self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled)
  491. # expotFileName = skeinforge_polyfile.getFileOrDirectoryTypesUnmodifiedGcode(self.fileNameInput.value, fabmetheus_interpret.getImportPluginFileNames(), self.fileNameInput.wasCancelled)
  492. if self.usePyPyforSlicing.value :
  493. for fileName in fileNames:
  494. os.getcwd()
  495. CommandOutput=os.popen('C:\pypy-1.9\pypy.exe %s%s %s' % (os.getcwd(),'\skeinforge_application\skeinforge_utilities\skeinforge_craft.py', fileName)).read() #for pypy slicing
  496. # print fileName
  497. print CommandOutput #for pypy slicing
  498. # print "Slicing finished....."
  499. # skeinlayer.writeOutput('', '', fileNamePenultimate,)
  500. fileNameSkeinLayer = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
  501. skeinlayer.writeOutput('', '', fileNameSkeinLayer, '')
  502. # fileNamePenultimate = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
  503. else:
  504. for fileName in fileNames:
  505. skeinforge_craft.writeOutput(fileName) #use this line instead of the below two for regular python slicing
  506. def save(self):
  507. 'Profile has been saved and profile menu should be updated.'
  508. self.profileType.removeMenus()
  509. self.profileSelection.removeMenus()
  510. addToProfileMenu(self.profileSelection, self.profileType, self)
  511. self.profileType.addRadiosToDialog(self.repositoryDialog)
  512. self.profileSelection.addRadiosToDialog(self.repositoryDialog)
  513. def main():
  514. 'Display the skeinforge dialog.'
  515. parser = OptionParser()
  516. parser.add_option(
  517. '-p', '--prefdir', help='set path to preference directory', action='store', type='string', dest='preferencesDirectory')
  518. parser.add_option(
  519. '-s', '--start', help='set start file to use', action='store', type='string', dest='startFile')
  520. parser.add_option(
  521. '-e', '--end', help='set end file to use', action='store', type='string', dest='endFile')
  522. parser.add_option(
  523. '-o', '--option', help='set an individual option in the format "module:preference=value"',
  524. action='append', type='string', dest='preferences')
  525. (options, args) = parser.parse_args()
  526. if options.preferencesDirectory:
  527. archive.globalTemporarySettingsPath = options.preferencesDirectory
  528. if options.preferences:
  529. for prefSpec in options.preferences:
  530. (moduleName, prefSpec) = prefSpec.split(':', 1)
  531. (prefName, valueName) = prefSpec.split('=', 1)
  532. settings.addPreferenceOverride(moduleName, prefName, valueName)
  533. sys.argv = [sys.argv[0]] + args
  534. if len( args ) > 0:
  535. writeOutput( ' '.join(args) )
  536. else:
  537. settings.startMainLoopFromConstructor(getNewRepository())
  538. if __name__ == '__main__':
  539. main()