From Mark CLohesy (Hiddensoul), 4 Months ago, written in Python.
This paste will hop the perch in 6 Months.
Embed
  1. #!/usr/bin/python
  2. # huskystar-C20-CNC.0.1.0.py
  3. # Version 0.1.0
  4. #
  5. # Linux-2.6.27-7, Python-2.5.2
  6. #
  7. # Embroidery CNC Code Generator for Huskystar C20 Sewing Machine
  8. # Programer-Mark Clohesy(MRC), Tester-Angus Smythe (AWS)
  9. #
  10. # This work is licensed under the Creative Commons
  11. # Attribution-Noncommercial-Share Alike 2.5 Australia License.
  12. # To view a copy of this license,
  13. # visit http://creativecommons.org/licenses/by-nc-sa/2.5/au/
  14. # or send a letter to Creative Commons, 171 Second Street, Suite 300
  15. # San Francisco, California, 94105, USA.
  16. #
  17. # Import modules
  18. import os
  19. import string
  20. import sys
  21. # Define initial values for program
  22. printmsg = ''
  23. # Welcome message
  24. welmsg = '''Welcome to the Huskystar C20 Monogram Program
  25. Please enter your text to convert to numeric
  26. code for entry in to your Huskystar Sewing Machine
  27. \nFor Help in using this program  type #help
  28. To see chracters accepted by the C20 type #type
  29. And to exit this program type #quit'''
  30. # Program usage instructions
  31. instructmsg = '''The Memory of the Huskystar c20 Machine is
  32. limited to 30 chracter's not including spaces.
  33. (Spaces are done manually by pausing between
  34. the end of words and moving the workpiece)\n
  35. This program will not include spaces when working out the
  36. length of your entry. So the text "Marks Ruler" is 10 letters long
  37. after removing the space.\n
  38. The program will indicate the end of words when the numeric code
  39. is generated with the word "stop", you will need to pause the
  40. work at this stage and move the workpiece before continuing
  41. \nFor Help in using this program  type #help
  42. To see chracters accepted by the C20 type #type
  43. And to exit this program type #quit'''
  44. # Type of chracters the C20 Machine can accept
  45. acceptmsg = '''The C20 can sew the following letters..
  46. \nA B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  47. \n1 2 3 4 5 6 7 8 9 0
  48. \nand the following symbols
  49. \n& ? ! . - \n
  50. For Help in using this program  type #help
  51. To see chracters accepted by the C20 type #type
  52. And to exit this program type #quit'''
  53. # Program flow starts here
  54. os.system("clear")
  55. print welmsg
  56. # Accepts A-Z 0-9 and & ? ! . - only supports uppercase but the program takes care of LC > UC conversion
  57. while True:
  58.     textconv = raw_input('\nType #help or text to convert:')
  59.     if textconv == '#quit':
  60.         print 'Thankyou and have a nice day.. \nExiting Now'
  61.         sys.exit(0)
  62.     if textconv == '#help':
  63.         os.system("clear")
  64.         print instructmsg
  65.         continue
  66.     if textconv == '#type':
  67.         os.system("clear")
  68.         print acceptmsg
  69.         continue
  70.     if textconv == '':
  71.         os.system("clear")
  72.         continue
  73. # String must be no longer then 30 chracters with whitespace removed
  74.     textconv.strip()
  75.     modmsg = string.join(textconv.split(), "")
  76.     if len(modmsg) < 31:
  77.         print 'Without spaces your text is ', len(modmsg), 'chracters in length'
  78.         print'The Length is okay'
  79.         break
  80. # String must be longer then 0 chracters with whitespace removed
  81.     if len(modmsg) == 0:
  82.         continue        
  83.     else:
  84.         print 'Without spaces your text is ', len(modmsg), 'chracters in length'
  85.         print 'Sorry that is to long, please shorten your message by', len(modmsg)-30, 'chracters'
  86.         continue
  87. # As we only process valid chracters we dont have to exclude invalid chracters from the string they are just ignored
  88. # Now construct the CNC code for output
  89. textconv = textconv.upper()
  90. length = len(textconv)
  91. for i in range(0, length):
  92.     replace = textconv[i:i+1]
  93.     if replace == 'A':
  94.         printmsg = printmsg + '11 '
  95.         continue
  96.     if replace == 'B':
  97.         printmsg = printmsg + '12 '
  98.         continue
  99.     if replace == 'C':
  100.         printmsg = printmsg + '13 '
  101.         continue
  102.     if replace == 'D':
  103.         printmsg = printmsg + '14 '
  104.         continue
  105.     if replace == 'E':
  106.         printmsg = printmsg + '15 '
  107.         continue
  108.     if replace == 'F':
  109.         printmsg = printmsg + '16 '
  110.         continue
  111.     if replace == 'G':
  112.         printmsg = printmsg + '17 '
  113.         continue
  114.     if replace == 'H':
  115.         printmsg = printmsg + '18 '
  116.         continue
  117.     if replace == 'I':
  118.         printmsg = printmsg + '19 '
  119.         continue
  120.     if replace == 'J':
  121.         printmsg = printmsg + '20 '
  122.         continue
  123.     if replace == 'K':
  124.         printmsg = printmsg + '21 '
  125.         continue
  126.     if replace == 'L':
  127.         printmsg = printmsg + '22 '
  128.         continue
  129.     if replace == 'M':
  130.         printmsg = printmsg + '23 '
  131.         continue
  132.     if replace == 'N':
  133.         printmsg = printmsg + '24 '
  134.         continue
  135.     if replace == 'O':
  136.         printmsg = printmsg + '25 '
  137.         continue
  138.     if replace == 'P':
  139.         printmsg = printmsg + '26 '
  140.         continue
  141.     if replace == 'Q':
  142.         printmsg = printmsg + '27 '
  143.         continue
  144.     if replace == 'R':
  145.         printmsg = printmsg + '28 '
  146.         continue
  147.     if replace == 'S':
  148.         printmsg = printmsg + '29 '
  149.         continue
  150.     if replace == 'T':
  151.         printmsg = printmsg + '30 '
  152.         continue
  153.     if replace == 'U':
  154.         printmsg = printmsg + '31 '
  155.         continue
  156.     if replace == 'V':
  157.         printmsg = printmsg + '32 '
  158.         continue
  159.     if replace == 'W':
  160.         printmsg = printmsg + '33 '
  161.         continue
  162.     if replace == 'X':
  163.         printmsg = printmsg + '34 '
  164.         continue
  165.     if replace == 'Y':
  166.         printmsg = printmsg + '35 '
  167.         continue
  168.     if replace == 'Z':
  169.         printmsg = printmsg + '36 '
  170.         continue
  171.     if replace == '&':
  172.         printmsg = printmsg + '37 '
  173.         continue
  174.     if replace == '?':
  175.         printmsg = printmsg + '38 '
  176.         continue
  177.     if replace == '!':
  178.         printmsg = printmsg + '39 '
  179.         continue
  180.     if replace == '.':
  181.         printmsg = printmsg + '40 '
  182.         continue
  183.     if replace == '-':
  184.         printmsg = printmsg + '41 '
  185.         continue
  186.     if replace == '1':
  187.         printmsg = printmsg + '01 '
  188.         continue
  189.     if replace == '2':
  190.         printmsg = printmsg + '02 '
  191.         continue
  192.     if replace == '3':
  193.         printmsg = printmsg + '03 '
  194.         continue
  195.     if replace == '4':
  196.         printmsg = printmsg + '04 '
  197.         continue
  198.     if replace == '5':
  199.         printmsg = printmsg + '05 '
  200.         continue
  201.     if replace == '6':
  202.         printmsg = printmsg + '06 '
  203.         continue
  204.     if replace == '7':
  205.         printmsg = printmsg + '07 '
  206.         continue
  207.     if replace == '8':
  208.         printmsg = printmsg + '08 '
  209.         continue
  210.     if replace == '9':
  211.         printmsg = printmsg + '09 '
  212.         continue
  213.     if replace == '0':
  214.         printmsg = printmsg + '10 '
  215.         continue
  216.     if replace == ' ':
  217.         printmsg = printmsg + 'stop '
  218.         continue
  219. else:
  220. # Format and display the CNC code
  221.     cncmsg = '''"''' + printmsg + ''' stop"'''
  222.     print '\nHere is the Numeric code for your C20\n'
  223.     print cncmsg    
  224. #EOF
  225.