If Operation-Comment includes text

If Operation-Comment includes text

Anonymous
Not applicable
631 Views
2 Replies
Message 1 of 3

If Operation-Comment includes text

Anonymous
Not applicable

I am a first time poster here and a new Fusion 360 user.  I've played with it a few times primarily in design.  My relevant experience is with MasterCam and SolidWorks.  Until yesterday, I had never touched Javascript.  I have successfully, adjusted a stock post to put out everything as I would like with the exception of a conditional string of M-codes based on the toolpath name.  I've made a few failed attempts and have no idea if I am getting closer or farther away.  Looking for some help.  Below are some screenshots of what I want to do:  name certain toolpaths, run through the post and result in code that looks like the last photo.  The post in its current condition and the latest error log are attached.


PrepostPrepostFaulty Post CodeFaulty Post CodeCheck Out That Feedrate!Check Out That Feedrate!

0 Likes
Accepted solutions (2)
632 Views
2 Replies
Replies (2)
Message 2 of 3

boopathi.sivakumar
Autodesk
Autodesk
Accepted solution

Hi @Anonymous

includes method is not supported currently so could use match method to achieve what you have wanted

  if (hasParameter("operation-comment")) {
    var comment = getParameter("operation-comment");
    var trim = comment.trim();
    var n =trim.match(/.{1,5}/g);  
    var k = n.slice(0,1);
    if (k){
        if ((k == "Board")|| (k == "BOARD")) {
          writeBlock(mFormat.format(05));
          writeBlock(mFormat.format(28));
          writeBlock(mFormat.format(122));
          writeBlock(mFormat.format(4001));
          writeBlock(mFormat.format(00) + ';Reload, then press Start');
          writeComment(comment);
          writeBlock('(UAO,99)');
          writeBlock(mFormat.format(121));
          writeBlock(mFormat.format(29));
          writeBlock(sOutput.format(spindleSpeed));
          writeBlock(mFormat.format(tool.clockwise ? 3 : 4));
        } else{
          writeComment(comment);
        }
    }
  }

It checks for the first 5 characters of the operation comment and if it Board or BOARD it will pass the comments else return the comment

It should work let me know how it goes

 

 


Boopathi Sivakumar
Senior Technology Consultant

Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thanks @boopathi.sivakumar,

This works exactly as desired.

0 Likes