gaziel / heekscnc

Automatically exported from code.google.com/p/heekscnc
Other
0 stars 0 forks source link

missing sapces in own language #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have used HeeksCNC to produce own CNC language code program Called "rez"

rez.py generates nc.tap with sapces...
rez_read.py reads program OK
but in output window, there are omitted spaces in the code, which is
incorrect for us.
saving also saves file without space, with both reguklar expresion and split()

both 
self.pattern_main =
re.compile(r'(\s+|,|-?\w\+?\d*(?:\.\d*)?|\w#\d+|\(.*?\)|#\d+=\+?\d*(?:\.\d*)?)')
words = self.pattern_main.findall(self.line)

and
words=self.line.split()

omits spaces.. 

and split is better for us, because it does not ommit "//" as a start of
comment line in our own language

Would anyone tell me how I can deal with this problem, when adding spaces
in words(X), when X is idex of space where space is required,please?

Original issue reported on code.google.com by peter.fo...@chello.sk on 24 Jul 2009 at 9:45

GoogleCodeExporter commented 9 years ago
Peter,
  I'm sorry I can't help you with the Python stuff.  It's just not something I'm good
at.  I just wanted to say that I am pleased that someone is looking at why all 
the
spaces are removed from the generated GCode.  It's something that annoys me.  I
believe the removal of spaces makes it much less readable and that the saving 
in disc
space is irrelevant.
  Thanks
  David Nicholls

Original comment by David.Ni...@gmail.com on 24 Jul 2009 at 11:13

GoogleCodeExporter commented 9 years ago
I like spaces too for the 'modern' controls that I have in my own shop. They 
make
things a lot more readable. However, I have seen cases where older Fanuc 
controls run
out of memory when there are spaces between all coordinates in long (over 64k)
programs. Those old controls can be a problem.
It might be good to be able to toggle the behavior for spaces.

Thanks,
Dan 

Original comment by ddfalck2...@yahoo.com on 24 Jul 2009 at 11:25

GoogleCodeExporter commented 9 years ago
This is another one of those times when I remember that I'm a programmer by 
trade and
a machinist by hobby.

Original comment by David.Ni...@gmail.com on 24 Jul 2009 at 11:31

GoogleCodeExporter commented 9 years ago
I have repeated this problem.
If I add a space to my nc file, then iso_read.py creates the xml file with text 
like
this:
    <ncblock>
        <text col="blocknum">N20</text>
        <text col="prep">G90</text>
        <mode units="1.0" />
        <text col="prep">G21</text>
        <text col="prep">G17</text>
        <text> </text>
        <text col="prep">G54</text>
    </ncblock>

( I added a space after G17 )
However this is not being read as a space!

The relevent code is in HeeksCNC/src/NCCode.cpp

void ColouredText::ReadFromXMLElement(TiXmlElement* element)
{
    m_color_type = CNCCode::GetColor(element->Attribute("col"));

    // get the text
    const char* text = element->GetText();

GetText() seems to ignore the space (       <text> </text>  )

I don't know how to fix this yet...
Sorry.

Original comment by danhe...@gmail.com on 25 Jul 2009 at 2:00

GoogleCodeExporter commented 9 years ago
Late yesterday I found solution to replace

self.add_text(word, col)

with
self.add_text(words, col)

with similar changes to lines, arcs and repadid moves

Original comment by peter.fo...@chello.sk on 25 Jul 2009 at 2:42

GoogleCodeExporter commented 9 years ago
Excuse me, not 
self.add_text(words,col)
but
self.add_text(self.line, col) 

Original comment by peter.fo...@chello.sk on 25 Jul 2009 at 2:45

GoogleCodeExporter commented 9 years ago
Dan, have a look in tinyxmlparser.cpp- there are references to removing 
whitespaces
or keeping them.

Original comment by ddfalck2...@yahoo.com on 25 Jul 2009 at 3:05

GoogleCodeExporter commented 9 years ago
It looks like in tinyxml.cpp this line is set to condense whitespaces(line 34):
 TiXmlBase::condenseWhiteSpace = true;

Here is a little bit of info:
http://www.grinninglizard.com/tinyxmldocs/classTiXmlBase.html#e0

Original comment by ddfalck2...@yahoo.com on 25 Jul 2009 at 3:13

GoogleCodeExporter commented 9 years ago
I presume this just adds the whole line.
Doesn't this lose the colors in the text?

I will try the solution suggested by Dan Falck.

>>peter.fo...@chello.sk, Jul 25 (3 days ago)

>>self.add_text(self.line, col) 

Original comment by danhe...@gmail.com on 28 Jul 2009 at 5:17

GoogleCodeExporter commented 9 years ago
This is fixed now.
We changed the py files to write
        <text><![CDATA[ ]]></text>
in the xml file, so that the spaces are not ignored

Original comment by danhe...@gmail.com on 1 Aug 2009 at 10:48

GoogleCodeExporter commented 9 years ago
peter.fo...@chello.sk, Is this fixed for you now?
Can you give us your rez.py and rez_read.py files, so we can add them to this 
project?

Original comment by danhe...@gmail.com on 1 Aug 2009 at 4:57