Dynomotion

Group: DynoMotion Message: 10206 From: eric_kato_sanders Date: 9/25/2014
Subject: Suggested improvement to KMotionCNC

Hi Tom,

Several times in the past I've had mechanical issues, (broken cutters, etc..) that caused me to want to start a multi operation GCode somewhere in the middle.  I would typically edit the file, then re-save as a delme.nc or such.  I never made use of the Block Delete option because it was too cumbersome to add all of the '/' tags at the start of the line.

What I added was code to toggle the line '/' prefix of all selected lines.  I added the appropriate code to include the option in the pop up context menu as well.  I know that the "Set Next Statement" option could be used, but it doesn't usually work if you are trying to skip over several arc commands.


ERic


void CRichEditCtrlEx::OnToggleBlock() 

{

   CString s = GetSelText();


   if (s.GetLength() == 0)

   {

      AfxMessageBox("Nothing Selected to Toggle");

      return;

   }


   int oldStart = 0;

   int newLine  = -1;

   while((newLine = s.Find("\n", newLine+1)) != -1)

   {

      if(s.GetAt(oldStart) == '/')

      {

         s.Delete(oldStart,1);

      }

      else

      {

         s.Insert(oldStart==0?oldStart:oldStart+1, '/');

         newLine++;

      }

      oldStart = newLine;

   }

   ReplaceSel(s);

}


Group: DynoMotion Message: 10213 From: Tom Kerekes Date: 9/26/2014
Subject: Re: Suggested improvement to KMotionCNC
Hi Eric,

Thanks.  This was merged into the code after fixing one bug.  We ended up with:

Does this work for you?

Regards
TK


void CRichEditCtrlEx::OnToggleBlock()
{
    CString s = GetSelText();

    if (s.GetLength() == 0)
    {
        AfxMessageBox("Nothing Selected to Toggle");
        return;
    }

    int oldStart = 0;
    int newLine  = -1;
    while((newLine = s.Find("\n", newLine+1)) != -1)
    {
        if(s.GetAt(oldStart) == '/')
        {
            s.Delete(oldStart,1);
            newLine--;       
        }
        else
        {
            s.Insert(oldStart, '/');
            newLine++;
        }
        oldStart = newLine+1;
    }
    ReplaceSel(s);
}




From: "eric@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Thursday, September 25, 2014 9:23 AM
Subject: [DynoMotion] Suggested improvement to KMotionCNC

 
Hi Tom,
Several times in the past I've had mechanical issues, (broken cutters, etc..) that caused me to want to start a multi operation GCode somewhere in the middle.  I would typically edit the file, then re-save as a delme.nc or such.  I never made use of the Block Delete option because it was too cumbersome to add all of the '/' tags at the start of the line.
What I added was code to toggle the line '/' prefix of all selected lines.  I added the appropriate code to include the option in the pop up context menu as well.  I know that the "Set Next Statement" option could be used, but it doesn't usually work if you are trying to skip over several arc commands.

ERic

void CRichEditCtrlEx::OnToggleBlock() 
{
   CString s = GetSelText();

   if (s.GetLength() == 0)
   {
      AfxMessageBox("Nothing Selected to Toggle");
      return;
   }

   int oldStart = 0;
   int newLine  = -1;
   while((newLine = s.Find("\n", newLine+1)) != -1)
   {
      if(s.GetAt(oldStart) == '/')
      {
         s.Delete(oldStart,1);
      }
      else
      {
         s.Insert(oldStart==0?oldStart:oldStart+1, '/');
         newLine++;
      }
      oldStart = newLine;
   }
   ReplaceSel(s);
}



Group: DynoMotion Message: 10223 From: eric_kato_sanders Date: 9/27/2014
Subject: Re: Suggested improvement to KMotionCNC
Hi Tom,
Yep, your code works fine.  I'm curious, what was the bug you found in what I had listed?  In testing, what I had seemed to work as well but it's easy to miss something.
Eric

Group: DynoMotion Message: 10224 From: TK Date: 9/28/2014
Subject: Re: Suggested improvement to KMotionCNC
Hi Eric,

It worked ok for me when all the lines selected were the the same - with or without block delete. But when selecting mixed lines it did weird things like not remove a slash or put a slash in after the G. 

Regards
TK

On Sep 27, 2014, at 8:37 PM, eric@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:

 

Hi Tom,

Yep, your code works fine.  I'm curious, what was the bug you found in what I had listed?  In testing, what I had seemed to work as well but it's easy to miss something.
Eric