585,975 active members*
4,459 visitors online*
Register for free
Login
Page 1 of 3 123
Results 1 to 20 of 57
  1. #1
    Join Date
    Sep 2009
    Posts
    96

    Building a software indexer Python 1

    Ok,
    I have to tell you guys out there to do a little search for;
    'Bucky Python tutorial You tube' and view his tutorials.
    Bucky Roberts, will give you the basics that you will need.
    He is a born 'educator', I really mean this.
    I am going to keep everything as simple as I can, but you have to help out
    a little.
    I will try to keep everything to a low level of complexity, but on a very few occasions I will have no choice but to go a little bit advanced.
    So, first go and learn from Bucky then come back to this.
    Buckys' style may seem a little entertaining, but when he uses what seems to be silly names during his tutorial, this is not entirely by chance.
    I kid you not, Python is an 'object' oriented programming language, so you better get creative with naming objects, else you will go nowhere, fast.

  2. #2
    Join Date
    Sep 2009
    Posts
    96
    I am going to start off by showing you how tell Python to read a single G-code word.
    We will of course add to this, until Python can read many words.
    From that point on, we will tell Python how to process the words in a similar way that an indexer would, or perhaps not quite the same way.
    The secrets of commercial indexers are guarded, so we can only assume.
    As far as Python is concerned, just how we achieve this is up to you and I.
    In the end, we will send through the computer port, logic 1/0 step and direction signals to some CNC stepper motor controller.

    Well, this all seems straight forward really, but be assured there will be a couple or 3,000 lines of Python code needed to get there.
    There are quick, but at the same time complex ,routes to get there, but few if any will learn anything by doing that.
    Be assured, that on the long road, you will learn allot.

  3. #3
    Join Date
    Sep 2009
    Posts
    96
    Now I'm going to have to assume that you have downloaded and installed
    Python 2.7 for windows sys32

  4. #4
    Join Date
    Sep 2009
    Posts
    96
    #
    Code:
    # anything preceded by #, is just my notes on the code.
    # Python will ignore my notes.
    # check to see, or make a folder on c drive called...  temp
    
    # then open windows notepad.
    # at the uppermost line, type in  G2 
    # ...capital letters won't matter
    # now 'save' that file 'as'  and name it ... test
    # make sure you save it to c:\\temp.
    # notepad will automatically give it the file extension .txt
    
    # Directly below are 3 Python code lines.
    
    import os
    import os.path
    import re
    
    
    # above we have simply allowed Python to bring in some modules,
    # that it will need to use at a later time.
    
    # now we can tell Python to open the same text file
    
    fileIN = open('c:/temp/test.txt','r')
    line = fileIN.readline()
    
    # Directly above,' line'  becomes the 'object' containing the file,
    # at least for as long as the program is running.
    # then the 'line' will be destructed (erased) from the computer's memory
    
    #=======================================================
    # The search function to read something on a file line is directly below
    #=======================================================
    
    def Find(pat, line):
         match = re.search (pat, line)
         if match: return match.group()
         else: return ""
    
    # now we have the search 'actual' with the detailed criteria
    
    def gSearch():
       gsearch = Find( r'G *\.*\d\d*\.*\d* *', line)
       if gsearch != "":
          gstring = (gsearch)
          gstrip = (gstring).strip()  # strip the white space here
          list (gstrip)            # the list(gstrip) now has no white space
          gword = list (gstrip)
          if gword [1] .isdigit:  # check if the 2nd character in list is a digit
                gletter = " G"
                glistnum = gword [1: ]
                gstringnum = "".join (glistnum)
                gnum = (gstringnum).strip() # strip white space from numbers
                g = int (gnum)
                gout = gletter + gnum
                return gout
       else:
          gletter = ""
          glistnum = ""
          gstringnum = ""
          gnum = ""
          g = ""
          gout = gletter + gnum
          return gout
    
    # 'fred' points to the search 'actual' and will now take on the returned value
    
    fred = gSearch()
    print fred
    
    # There's allot here I reckon, that I'm going to have to explain, 
    # but if you copy and paste this into a 'new' idle window,
    # Then save it as test.py
    # we have a starting point at least.
    # when you have saved this, select 'run' from the dropdown menu,
    # then click on run module 
    # you will get printed on the Python IDLE
    #>
    #> G2
    #>
    # Python has now collected the first G-code word
    #

  5. #5
    Join Date
    Sep 2009
    Posts
    96
    'Houston had a problem',
    Needed a Zone expert to sort the problem out.

  6. #6
    Join Date
    Jan 2010
    Posts
    2141
    Have you tried clicking on the # icon above the editor to wrap 'code' tags around the code?

  7. #7
    Join Date
    Sep 2009
    Posts
    96
    thanks doorknob your the expert

  8. #8
    Join Date
    Sep 2009
    Posts
    96
    Now to desribe some of the Python code.
    Any experienced Py users will probably start yawning right about...now.
    This for everyone else.
    import os
    import os.path
    import re
    As for the above, many Python modules are written in the language C.
    C is powerfull and also very very fast.
    I love C
    But we don't have to know about C
    Python will implement the C for us.

    fileIN = open('c:/temp/test.txt','r')
    line = fileIN.readline()
    To be safe, the file can also be closed like this;
    fileIN.close()
    The variable object named 'line', will still have the 'string' text.

    Next;
    In the smaller function called; def Find(pat, line):
    We could also call this a 'method' as well, because here, we are telling
    Python, just what method it should use to accomplish a task for us at some
    time later in our little program.
    Enclosed in the parentheses we have the 2 words 'pat' and 'line'.

    The function is going to expect to be told what (pat, line) actualy are,
    somewhere within the body of the function as a whole.

    So immediately below and 'indented', to tell Python that this is still part
    of the function, we give it a variable called 'match'

    The value assigned to 'match' is a 'search method' and it is going to
    use 're' as in 'regular expressions' as it's tools to conduct a search.
    The re.search is going to look for some kind of 'pat'(pattern) and it must
    look for a variable object called 'line' that will have a 'string' of
    text for it to examine. We can call examine 'iterate'.

    The variable object called 'line' is outside the function, and it is the
    one we created previously by opening the file called test.txt.

    Now we will argue 'if' and 'else'
    'if there is a match, give me back what ever that match happens to be.'
    A function really needs to give back something, because that's what it does.
    So we tell it that it can give us something else if it can't find anything.
    'else give me back an empty string of text.'
    "", is an empty string.

    Now we can look at the function def gSearch():
    We also give a function name a capital letter somewhere in that name.
    The role of this function is to find 1 G-code word and is an example.
    This can be written in different ways to get various returns.
    It can be as complex or as simple as you want it to be.

    On line 2, we have a variable object called gsearch.
    You'll notice that it doesn't have a capital letter S in it.
    Then we call the function 'Find' and within the parentheses we have our
    re 'regular expressions' which are the tools and the variable 'line' that
    is the variable object 'string' that's going to get examined or 'iterated over'.

    ( r'G* *\.*\d\d*\.*\d* *', line)
    r = kind of means, don't get upset about some strange characters it may see
    in the string of text, just do as you're told.
    ' = signifies the start of the string being searched
    G = look for a capital G
    * = this means 'none, one or more occurances of'
    G* = see here I've placed it next to the G, that's the letter it'll look after.

    Now there is a whitespace and another * just in case there are space gaps.
    . = a period can also be a command, so we have to tell the search function
    to see it as an actual period.
    \. we put a backslash just before it which means 'to treat as text only'
    and therefore it'll see it as just a 'period'.
    \.* I put the asterix with it also, cause there may or may not be one present.
    d = means what it is, look for a d character, but we really want a digit, so
    \d = means look for a 'd' short for 'digit' or 'integer'
    \d* = then I did this again in case there was another one, or more.
    \.* = then I did this again in case there was another period.
    \d* = then I did this again in case there was another digit, or more.
    Then I look for any other spacegaps 'whitespace'
    ' = signifies the end of the string being searched

    This isn't a prefect world, so we should make allowances.
    you can vary your search
    This will find the lower case g also.
    ( r'G*g* *\.*\d\d*\.*\d* *', line)

    This will allow for any space gap 'whitespaces' before the G.
    ( r' *G*g* *\.*\d\d*\.*\d* *', line)

    You may want to save you're little program with different titles.
    Make sure any new Py file you make ends with the extension .py
    Then mess around with the 're' search tools.
    To test your searching, you can alter the way that the G2 word is typed
    in the file test.txt;
    try g 2 or G2 or G21.1 or g 21.1
    Don't forget, we are only wanting to get back 1 word and remember to save
    each time you change the text.
    The idea is to be able to get the word, even if it isn't perfectly formed.
    If you haven't got too carried away, you should notice that the function
    gives you back the correct word all packaged nice and tidy.
    This isn't by accident.

    In your test.txt file, if you type X2, the search function will give you
    back nothing but an empty line.
    This can be a good thing later on.
    Sometimes we will want to completely ignore some words on purpose.

    I'll get to the the rest of the search function shortly, where I'll
    explain how it cleans everything up.
    Then we can go look for any other G-code word we want.
    To kind of 'set the scene' here,
    'really big' programs are actually made up of a whole bunch of 'really small'
    programs, at least that's how I look at it.
    For each 'small' program we make, we will test it to make sure it works for us,
    before we start joining our 'small' programs together.
    In the end, there'll be quite a few.
    As we progress, I'll need to explain a whole lot less as well.
    Anyway have a little play around with what we have so far.

  9. #9
    Join Date
    Sep 2009
    Posts
    96
    A small note about playing with the G2 word in the text file.
    If you change you're text file G2 word to having a decimal number,
    like this: G21.1
    The search, def gSearch(): is probably going to hang up on you.

    You would need to go down to the 'if' part of the function and change;
    g = int (gnum) to g = float (gnum)

    Or you could just delete g = int (gnum) altogether.
    If you do this, go to the 'else' section below that and also
    delete g = ""

    I have included g = int (gnum) because I'm not really going to
    want to find 'G' words with decimal numbers and the search line is
    going to reflect that also.
    I'll be looking for G0 G1 G2 G3

  10. #10
    Join Date
    Sep 2009
    Posts
    96
    continuing the description of def gSearch():
    1;
    if gsearch != "":
    The search is going to return either a match to the search,
    or an empty string.
    This means, if the return is not equal to an empty string, then continue
    with the next lines of code. Otherwise ignore the rest of the code following
    the 'if' and go directly to the 'else' statement and read those lines of
    code instead.
    2;
    I will assume the answer to 'if' was True.
    gstring = (gsearch)
    the return from the search may have been contained within a 'tuple'()
    (' G 2 ') this is what it would look like.
    We just want the string on it's own, so we create an object than takes on
    the value of what is inside of the tuple.
    gstring = ' G 2 ' gstring would look like this.
    3;
    Now we need to tidy up the string a little.
    gstrip = (gstring).strip() # strip the white space here
    We have just created a new object named 'gstrip' and in the same process,
    any white space (space gaps) will be stripped from either side of the group
    of text whether white space is present or not.
    gstrip = 'G 2' gstrip will now look like this
    4;
    We can't strip the white space inside the group of text in the string,
    so we will side step and change our approach.
    list (gstrip)
    gstrip has now been saved temporarily in memory as a 'list'.
    gword = list (gstrip) gword is a new variable oject that will take on the
    value of the entire list.
    gword = ['G','','','2'] this is what 'gword' would look like.
    5;
    if gword [1] .isdigit:
    Elements in lists are found by a numerical order starting from 0
    'G' would reside at position 0 in the list and '2' would be at position 3.
    .isdigit: will look for a digit and return 'True' if the next character seen
    is in fact a digit.
    [1], using this tells .isdigit, to start looking from position 1, which is a
    white space and keep looking at each position in turn, until it finds a
    digit. When it does, .isdigit will return 'True'.
    6;
    I will assume it found the 2, so the return is True.
    gletter = " G"
    Here we have created a variable and assigned to it a string, " G".
    The g letter that was found in the search is now no longer needed.
    7;
    glistnum = gword [1: ]
    Here, we have a new variable named 'glistnum' and it is going to take on
    the value of the list 'gword'.
    [1: ] this states that the new list will only include elements from the
    position 1 and any other element from then on, to the end of the list.
    glistnum = ['','','2'] here, the G is no longer included the new list.
    We will now be able to get rid of the white spaces.
    8;
    gstringnum = "".join (glistnum)
    'gstringnum' is a new variable and we have assigned it a 'string' and
    .join takes all elements in the list glistnum to create the string.
    9;
    gnum = (gstringnum).strip()
    Now we have yet another new variable and during it's creation, .strip()
    will remove any remaining white space.
    gnum = '2'
    10;
    g = int (gnum)
    The new variable g will take on the value of 'gnum' and 'int' will change
    the 2, from being a text element, to a 'real' and processable number 2.
    in this instance the number 2 will be an integer.
    If 'int' where changed to 'float' then the number would become a float number
    with a decimal point, as in, 2.0
    11;
    gout = gletter + gnum
    Here, a new variable 'gout' is assigned the value of the 2 string variables,
    'gletter' and 'gnum'
    gout = ' G2' this is how it would look
    12;
    return gout
    The output from the function will be;
    G2
    13;
    The else: statement
    If the return of 'gsearch' was in fact equal to "", (an empty string),
    the lines in the 'else' statement will be examined and any command will be
    carried out. Simply put, each variable will be assigned an empty string,
    to clear out anything unwanted residing in the variables of the 'if' blocks.

  11. #11
    Join Date
    Sep 2009
    Posts
    96
    Let's look at fileIN again;

    fileIN = open('c:/temp/test.txt','r')
    line = fileIN.readline()

    'fileIN', is used here instead of 'Fob'
    'Fob' which means 'file object' takes the file that is called by it's address
    and creates a temporary object in memory containing everything within that
    file. From that point, a program can examine the file (iterate over it).
    If the file is large, alot of memory will be used.

    'fileIN' brings into memory, 1 line of the file at a time, and therefore if
    the file were very big, only a small amount of memory is used at any time.
    This is why I didn't bother with 'fileIN.close()' to close the file.
    If, while using fileIN, the file is opened, the first line is read,
    then closed, we won't be able to read another line unless the file is
    re-opened and then you would get the first line again.
    We would use 'fileIN' when we use a 'looping process' to read the file, line
    after line, until the very end.
    During a loop, we can do 1 or 2 or thousands of operations before proceding
    to the next line.
    'fileIN' will wait happily, until we command it to bring in the next line.
    We then get the next file line by just re-stating;
    line = fileIN.readline
    The process can begin again with the next line in the file.

    When the entire job is done, we could then use;
    fileIN.close()
    Even then we don't have to.

    We can also make our search a little easier;
    We can tell the program to do a little extra when fileIN,
    brings in each new text line.

    fileIN = open('c:/temp/test.txt','r')
    line1 = fileIN.readline()
    line = line1.upper()
    .upper(), changes all text letters to upper case, regardless of whether
    they are already capital letters or not.

    Our 're' search line can remain as it is;
    gsearch = Find( r' *G *\.*\d\d*\.*\d* *', line)

  12. #12
    Join Date
    Sep 2009
    Posts
    96
    The gsearch function is just an example and it is limited to just giving
    back (returning) to you, a string which is the G-code word you were searching
    for.
    But you will notice in the 'if' section, it creates a 'real' number from the
    text number it has found.
    We can have the function give this 'real number' back to us as well.

    In the 'if' section, instead of;
    return gout
    we add to this;
    return gout,g
    In the 'else:' section, instead of;
    return gout
    We do the same;
    return gout,g

    The function will return to us a tuple() containing both gout and g

    We can call the function into action using a variable like this;
    fred = gSearch() # fred will get back the tuple from the function

    'fred' will take on these values like this;
    fred = ('G2',2) where G2 is a string and the 2 is a real processable number.
    We now only need to extract the elements from the tuple, to make use of them.

  13. #13
    Join Date
    Sep 2009
    Posts
    96
    Here is new code to get the word and a working extraction scenario.
    The extraction, although colorful, does it's job.
    As time goes on, you will need to be colorful when naming things.
    Of course 'fred', 'harry' is a little silly.
    You'll notice that the extraction methods are similar to the search function.

    Code:
    import os
    import os.path
    import re
    
    fileIN = open('c:/temp/test.txt','r')
    line1 = fileIN.readline()
    line = line1.upper() # change all text to upper case
    
    #==============================================================
    # The search function to Parse a file line is directly below
    #==============================================================
    def Find(pat, line):
         match = re.search (pat, line)
         if match: return match.group()
         else: return ""
    #==============================================================
    # The search 'actual', is directly below
    #==============================================================
    def gSearch():
       gsearch = Find( r' *G *\.*\d\d*\.*\d* *', line)
       if gsearch != "":
          gstring = (gsearch)
          gstrip = (gstring).strip()
          list (gstrip)
          gword = list (gstrip)
          if gword [1] .isdigit:
                gletter = ' G'
                glistnum = gword [1: ]
                gstringnum = "".join (glistnum)
                gnum = (gstringnum).strip()
                g = float (gnum)
                gout = gletter + gnum
                return gout,g
       else:
          gletter = ''
          glistnum = ''
          gstringnum = ''
          gnum = ''
          g = ''
          gout = gletter + gnum
          return gout,g
    
    fred = gSearch() # fred will get back, gout and g, again within a 'tuple'()
    if fred != ('',''):
       print "This is what we get back from the search"
       print fred, " We can't do much with a tuple"
       tom = list (fred) # tom = fred which is now a list containing gout and g
       print tom, """
    So now we've made a list from what we found in the tuple.
    We can do things with items in a list.
    """
       dick = tom [1: ]  # dick is now equal to g only
       print dick[0], """
    this is the G words' number in our list and unlike a string, it's a real number.
    Meaning we can go ahead and process this using math if we want.
    If it was from an axis word like X, Y or Z, we might want to do something
    with it, like, add 1 to the number.
    """
       harry = dick[0]
    
       thenumber = harry + 1
       print thenumber, " Within reason of course, we can do as we please, with it."
    else:
        print "No G word found"
    
    fileIN.close()

  14. #14
    Join Date
    Sep 2009
    Posts
    96
    Now we have the basis for all G-code word searches.
    Only slight variations of the 're' search 'tools' will be needed for different
    G-code word types.

    We will look at these different word searches.
    Then we will look at how to create our program folders, files, read from them
    in different ways and write to them.

    We are going to need to create configuration files that will contain
    information, critical to giving our program the ability to do useful things
    for us.

  15. #15
    Join Date
    Sep 2009
    Posts
    96
    Just a small note about this thread.
    This is the public domain and as such, anything I write here, including code that I write, can be used, altered in any way and reproduced in any form, by anyone at any time.
    My posts are in the spirit of D.I.Y. and to inspire others.
    What I write is in no way intended to cause harm to any commercial enterprise.
    So I must make this clear;
    At any point, if it is considered possible that a post may cause harm to the commercial interests of anyone, out of respect for their hard work, I would withdraw the post without question.
    If there seems no way to continue without the possibility of harm, I will stop this thread.

  16. #16
    Join Date
    Sep 2009
    Posts
    96
    lets get on to other search functions;
    Here is the basic function, altered slightly to find an X word.
    This looks very similar to gSearch(): in many ways.


    Code:
    def xSearch():
       xsearch = Find( r'X *-*\.*\d\d*\.*\d* *', line)  #(look at the 're' tool box)
       if xsearch != "":
          xstring = (xsearch)
          xstrip = (xstring).strip()
          list (xstrip)
          xword = list (xstring)
          if xword [1].isdigit or xword [2].isdigit:
             xletter = " X"
             xlistnum = xword [1: ]
             xstringnum = "".join (xlistnum)
             xnum = (xstringnum).strip()
             x = float (xnum)
             xout = xletter + xnum
             return xout,x
       else:
          xletter = ""
          xlistnum = ""
          xstringnum = ""
          xnum = ""
          x = ""
          xout = xletter + xnum
          return xout,x

  17. #17
    Join Date
    Sep 2009
    Posts
    96
    The major change here is;
    xsearch = Find( r'X *-*\.*\d\d*\.*\d* *', line)
    Notice the - symbol in the 're' search toolbox?

    There can be negative values associated with Gcode command words.
    So this keeps a lookout for that possibility.

    You can now re-create this for every other Gcode word you want to pick up.
    Just change the first letter of every variable and function name to;
    Y,Z,I,J.
    If you want to include for any reason, A,B,C,K, that's up to you.
    But for now, I won't be including these.
    For learning to be easier, I have to be restrictive.
    This is going to get a whole lot more confusing as it is, without adding
    not really needed functions into the mixture.

    F, P and M word 're' searches, don't need the - symbol.
    Just use the gSearch 're' toolbox.
    gsearch = Find( r' *G *\.*\d\d*\.*\d* *', line)

    When you have re-created you're search functions, just arrange them
    one after the other.
    Don't include any 'call to the function' code lines yet.
    fred = gSearch() # remember this, it's a call made by a variable.
    We'll get to that later.
    We won't be using 'fred', 'dick' or 'harry' names either.
    We will be conservative and try to behave like we know what we're doing.
    As seen with the search functions, the calls will also be similar.
    But we will still need to be creative with our function calls.

  18. #18
    Join Date
    Sep 2009
    Posts
    96
    Let's quickly look at 'calling our search functions'.
    We can always come back and look at 1 or 2 of these later on.
    We may need to look at G and Z.
    Notice how most all of these are practically the same?.
    Computers love it.


    Code:
    getg = ''
    lineg = ''
    mygsearch = gSearch()
    if mygsearch != ('',''):
      mygsearchlist = list (mygsearch) 
      getg = mygsearchlist [0]
      thegnum = mygsearchlist [1: ]
      lineg = thegnum[0]
    gpresent = 0
    g = None
    if lineg !='':
      gpresent = 1
      g = lineg
    #=======================
    getm = ''
    linem = ''
    mymsearch = mSearch()
    if mymsearch != ('',''):
      mymsearchlist = list (mymsearch) 
      getm = mymsearchlist [0]
      themnum = mymsearchlist [1: ]
      linem = themnum[0]
    mpresent = 0
    m = None
    if linem !='':
      mpresent = 1
      m = linem
    #=======================
    getx = ''
    linex = ''
    myxsearch = xSearch()
    if myxsearch != ('',''):
      myxsearchlist = list (myxsearch) 
      getx = myxsearchlist [0]
      thexnum = myxsearchlist [1: ]
      linex = thexnum[0]
    xpresent = 0
    x = None
    if linex !='':
      xpresent = 1
      x = linex
    #=======================
    gety = ''
    liney = ''
    myysearch = ySearch()
    if myysearch != ('',''):
      myysearchlist = list (myysearch) 
      gety = myysearchlist [0]
      theynum = myysearchlist [1: ]
      liney = theynum[0]
    ypresent = 0
    y = None
    if liney !='':
      ypresent = 1
      y = liney
    #=======================
    getz = ''
    linez = ''
    myzsearch = zSearch()
    if myzsearch != ('',''):
      myzsearchlist = list (myzsearch) 
      getz = myzsearchlist [0]
      theznum = myzsearchlist [1: ]
      linez = theznum[0]
    ypresent = 0
    z = None
    if linez !='':
      zpresent = 1
      z = linez
    #=======================
    geti = ''
    linei = ''
    myisearch = iSearch()
    if myisearch != ('',''):
      myisearchlist = list (myisearch) 
      geti = myisearchlist [0]
      theinum = myisearchlist [1: ]
      linei = theinum[0]
    ipresent = 0
    i = None
    if linei !='':
      ipresent = 1
      i = linei
    #=======================
    getj = ''
    linej = ''
    myjsearch = jSearch()
    if myjsearch != ('',''):
      myjsearchlist = list (myjsearch) 
      getj = myjsearchlist [0]
      thejnum = myjsearchlist [1: ]
      linej = thejnum[0]
    jpresent = 0
    j = None
    if linej !='':
      jpresent = 1
      j = linej
    #=======================
    getf = ''
    linef = ''
    myfsearch = fSearch()
    if myfsearch != ('',''):
      myfsearchlist = list (myfsearch) 
      getf = myfsearchlist [0]
      thefnum = myfsearchlist [1: ]
      linef = thefnum[0]
    fpresent = 0
    f = None
    if linef !='':
      fpresent = 1
      f = linef
    #=======================
    getp = ''
    linep = ''
    mypsearch = pSearch()
    if mypsearch != ('',''):
      mypsearchlist = list (mypsearch) 
      getp = mypsearchlist [0]
      thepnum = mypsearchlist [1: ]
      linep = thepnum[0]
    ppresent = 0
    p = None
    if linep !='':
      ppresent = 1
      p = linep

  19. #19
    Join Date
    Sep 2009
    Posts
    96
    So far, in our little program,
    we should now have, starting from the top and
    running down like the flow of a waterfall;

    1: import the needed python process modules
    2: open a file to read
    3: search function(method)
    4: all search 'actual' functions
    5: all calls to the 'actual' functions

    Now go to your test.txt file in your temp folder and type a bunch of
    G-code words on the first and only line.

    To have the program pick up, process, then print out that line in the
    Python IDLE,
    you'll need these 2 lines at the end of your program;

    #================================================= =========
    output = getg+getm+getx+gety+getz+geti+getj+getf+getp
    print output
    #================================================= =========

    It won't matter if you don't include one word on the file line of
    your text file.
    The program will only print out what it finds on that line.

    If all is well, we are getting somewhere.
    If you have any problem, post here and I will upload the entire program
    so far.

    Now, there is still a long way to go, after all, our little program is
    completely blind.
    It can do nothing unless we tell it.
    We will need to tell it how to make some decisions for itself.
    This isn't that hard to do, we just have to take it one step at a time.

  20. #20
    Join Date
    Jan 2010
    Posts
    2141
    I'm sure that I'm not the only one who is following your posts, but you're way ahead of me - I may not catch up until next weekend.

    But don't let me hold you back...


Page 1 of 3 123

Similar Threads

  1. Read variable with Python
    By albova in forum LinuxCNC (formerly EMC2)
    Replies: 7
    Last Post: 05-26-2012, 12:53 PM
  2. Building a software Indexer
    By bernster in forum Australia, New Zealand Club House
    Replies: 48
    Last Post: 07-08-2011, 07:41 PM
  3. G-code programming library in python
    By bermanmk in forum G-Code Programing
    Replies: 1
    Last Post: 11-10-2009, 03:24 AM
  4. Indexer software
    By Art Ransom in forum Wood Lathes / Mills
    Replies: 4
    Last Post: 07-15-2008, 11:47 PM
  5. just another python gcode thing
    By cyclestart in forum LinuxCNC (formerly EMC2)
    Replies: 8
    Last Post: 02-18-2008, 03:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •