Change "notes" into NC code

Change "notes" into NC code

FTKnur
Collaborator Collaborator
665 Views
3 Replies
Message 1 of 4

Change "notes" into NC code

FTKnur
Collaborator
Collaborator

I want to change all lines that begins with "#" to change into a direct NC-Code:

 

Check tool!

#Q215=2

 

should look in the NC-Code:

;Check tool     <-- Comment

Q215=2            <-- NC-Code

 

I tried a little bit with this post:

https://forums.autodesk.com/t5/hsm-post-processor-forum/control-variable-thru-notes/m-p/6373339#M992...

but I don't get it to work.

 

Can someone help me with this?

 

 

original PP:

 

  if (properties.showNotes && hasParameter("notes")) {
    var notes = getParameter("notes");
    if (notes) {
      var lines = String(notes).split("\n");
      var r1 = new RegExp("^[\\s]+", "g");
      var r2 = new RegExp("[\\s]+$", "g");
      for (line in lines) {
        var comment = lines[line].replace(r1, "").replace(r2, "");
        if (comment) {
          writeComment(comment);
        }
      }
    }
  }

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

makko74
Collaborator
Collaborator
Accepted solution

Hallo @FTKnur,

mal mit folgendem Codeschnippsel versuchen..

  if (properties.showNotes && hasParameter("notes")) {
    var notes = getParameter("notes");
    if (notes) {
      var lines = String(notes).split("\n");
      var r1 = new RegExp("^[\\s]+", "g");
      var r2 = new RegExp("[\\s]+$", "g");
      for (line in lines) {
        var zeile = lines[line].replace(r1, "").replace(r2, "");
        if (zeile[0]=="#") {
          writeBlock( zeile.split("#")[1].trim() );
        } else {
          writeComment( zeile );
        }
      }
    }
  }

Gruß

Mario



InfoInventor CAM(Ultimate) user --- Inventor Professional 2021.2 + Inventor CAM Ultimate 8.1.2.21785
0 Likes
Message 3 of 4

GeorgeRoberts
Autodesk
Autodesk
Accepted solution

Hello,

 

Thanks for posting! Perhaps this code will do what you are looking for:

  if (hasParameter("notes")) {
    var notes = getParameter("notes");
    var lines = notes.split("\n");
    for (var i = 0; i < lines.length; ++i) {
      if (lines[i].charAt(0) == "#") {
        writeBlock(lines[i].substr(1, lines[i].length - 1));
      } else {
        writeComment(lines[i]);
      }
    }
  }
-

George Roberts

Manufacturing Product manager
If you'd like to provide feedback and discuss how you would like things to be in the future, Email Me and we can arrange a virtual meeting!
0 Likes
Message 4 of 4

FTKnur
Collaborator
Collaborator

Vielen dank @makko74,

 

hat genau das bewirkt, was ich wollte 🙂

 

 

Thanks @GeorgeRoberts,

 

yours works too but add after each comment line a blank line in the code. This from Mario works perfect!

0 Likes