Example #1
0
def parse(inputstring):
    "parse(inputstring): returns a parsed output string"
    print "postprocessing..."

    output = ""
    params = ['X', 'Y', 'Z', 'A', 'B', 'I', 'J', 'K', 'F', 'S',
              'T']  #This list control the order of parameters

    # write some stuff first
    if OUTPUT_HEADER:
        print "outputting header"
        output += "'Exported by FreeCAD\n"
        output += "'Post Processor: " + __name__ + "\n"
        output += "'Output Time:" + str(now) + "\n"

    #Write the preamble
    if OUTPUT_COMMENTS: output += "'begin preamble\n"
    for line in PREAMBLE.splitlines(True):
        output += line

    # treat the input line by line
    lines = inputstring.splitlines(True)

    for line in lines:
        commandline = PostUtils.stringsplit(line)
        command = commandline['command']
        try:
            print commandline
            print "command: " + command
            print command in scommands
            output += scommands[command](commandline)
        except:
            print "I don't know what the hell the command:  " + command + " means.  Maybe I should support it."

    print "finished"
    # write some more stuff at the end
    if OUTPUT_COMMENTS: output += "'begin postamble\n"
    for line in POSTAMBLE.splitlines(True):
        output += line

    if SHOW_EDITOR:
        dia = PostUtils.GCodeEditorDialog()
        dia.editor.setText(output)
        result = dia.exec_()
        if result:
            final = dia.editor.toPlainText()
        else:
            final = output
    else:
        final = output

    print "done postprocessing."
    return final
Example #2
0
def parse(inputstring):
    "parse(inputstring): returns a parsed output string"
    print "postprocessing..."
    
    output = ""
    params = ['X','Y','Z','A','B','I','J','K','F','S','T'] #This list control the order of parameters
 
    # write some stuff first
    if OUTPUT_HEADER:
        print "outputting header"
        output += "'Exported by FreeCAD\n"
        output += "'Post Processor: " + __name__ +"\n"
        output += "'Output Time:"+str(now)+"\n"

    #Write the preamble 
    if OUTPUT_COMMENTS: output += "'begin preamble\n"
    for line in PREAMBLE.splitlines(True):
        output += line

    # treat the input line by line
    lines = inputstring.splitlines(True)

    for line in lines:
        commandline = PostUtils.stringsplit(line)
        command = commandline['command']        
        try:
            print commandline
            print "command: " + command
            print command in scommands
            output += scommands[command](commandline)
        except:
            print "I don't know what the hell the command:  " + command + " means.  Maybe I should support it."

    print "finished"    
    # write some more stuff at the end
    if OUTPUT_COMMENTS: output += "'begin postamble\n" 
    for line in POSTAMBLE.splitlines(True):
        output += line

    if SHOW_EDITOR:
        dia = PostUtils.GCodeEditorDialog()
        dia.editor.setText(output)
        result = dia.exec_()
        if result:
            final = dia.editor.toPlainText()
        else:
            final = output
    else:
        final = output

    print "done postprocessing."
    return final
Example #3
0
def parse(inputstring):
    "parse(inputstring): returns a parsed output string"

    state = { 'X': 0.0, 'Y': 0.0, 'Z': 0.0, 'XYspeed': -1.0, 'Zspeed': -1.0 }
    output = []

    # header
    output += addheader()
    output += motoron()

    output += speed(2.0, 1.0, state) # defaults

    # TODO: respect clearance height

    # treat the input line by line
    lines = inputstring.split("\n")
    for line in lines:
        if not line:
            continue
        parsed = PostUtils.stringsplit(line)
        command = parsed['command']
        print('cmd', line)
        try:
            if command:
                code = convertgcode(command, parsed, state)
                if not isinstance(code, list):
                    code = [ code ]
                if len(code) and code[0]:
                    output += code
        except NotImplementedError as e:
            print(e)

    # footer
    output += motoroff()
    output += home()
    output += addfooter()

    return '\n'.join(output)
Example #4
0
def parse(inputstring):
    "parse(inputstring): returns a parsed output string"

    state = {'X': 0.0, 'Y': 0.0, 'Z': 0.0, 'XYspeed': -1.0, 'Zspeed': -1.0}
    output = []

    # header
    output += addheader()
    output += motoron()

    output += speed(2.0, 1.0, state)  # defaults

    # TODO: respect clearance height

    # treat the input line by line
    lines = inputstring.split("\n")
    for line in lines:
        if not line:
            continue
        parsed = PostUtils.stringsplit(line)
        command = parsed['command']
        print('cmd', line)
        try:
            if command:
                code = convertgcode(command, parsed, state)
                if not isinstance(code, list):
                    code = [code]
                if len(code) and code[0]:
                    output += code
        except NotImplementedError as e:
            print(e)

    # footer
    output += motoroff()
    output += home()
    output += addfooter()

    return '\n'.join(output)