In which order functions are called, and how to use/change it?

In which order functions are called, and how to use/change it?

bernard5BABD
Advocate Advocate
218 Views
1 Reply
Message 1 of 2

In which order functions are called, and how to use/change it?

bernard5BABD
Advocate
Advocate

Not sure about phrasing properly the title of my question.
Still working on the Roeders 5 axis post-processor. The way it is used, it generated a file for each operation/toolpath. Problem is, the subprogram file name is always the same "subx.rod", which is not very convenient after you process a dozen of parts....
So, I would like to add the document-path parameter to the filename. I saw that, if I get those parameters values at the top of the "onSection" function, it does works.

 

 

 

function onSection() {

  if (isFirstSection()){
      // BG Added to have the actual document name
    if (hasParameter("document-path")){
      var documentName = getParameter("document-path");
      //writeComment(" --Document: " + documentName + " -- ");
    }
    // BG added to get the setup description before each operation.
    if (hasParameter("job-description")){
      var setupName = getParameter("job-description");
      //writeComment(" --Setup: " + setupName + " -- ");
    }
  }

 

 

 


BUT, if I try to use "documentName" in subprogramCall, the value is undefined, so I guess it's called before. What would be the proper workaround ?

 

 

 

function subprogramCall() {
  if (getProperty("useFilesForSubprograms")) {
    writeBlock("XCALL "  + documentName + "sub" + currentSubprogram + "." + subprogramExtension); // call subprogram
  } else {
    writeBlock("CALL LBL"  + documentName +  currentSubprogram);
  }
}

 

 

 

As always, than you so much for your help,
Bernard

PS- Also, I notice theses parameters are under onOpen() in the dmp file, but I get "parameter does not exist" when I put my onSection code in the onOpen function. As I doubt the dmp file is wrong, I guess I am doing something wrong, but what ? I don't understand why I could not read these values, but the dump.cps can.

Bernard Grosperrin, Retired, Maker, and Autodesk Certified Instructor
Blog : Le Bear CNC | Forum : Le Bear CNC Forum | Addin : Airfoil Sketch from file
0 Likes
Accepted solutions (1)
219 Views
1 Reply
Reply (1)
Message 2 of 2

bernard5BABD
Advocate
Advocate
Accepted solution

Well, I found that I could add the request to read these parameters the "onParameter" function, and it does work. I thoughts about doing this, but as I can't see WHEN this function is called I was reluctant to do so. It works well, so I guess this must be called very early, maybe with onOpen ?

function onParameter(name, value) {
  if (name == "operation-structure-comment") {
    writeStructureComment("  " + value);
  }
  if (name == "probe-output-work-offset") {
    probeOutputWorkOffset = (value > 0) ? value : 1 ;
  }
  if (name == "document-path"){
    documentName = value;
  }
  if (name == "job-description"){
    setupName = value;
  }
}
Bernard Grosperrin, Retired, Maker, and Autodesk Certified Instructor
Blog : Le Bear CNC | Forum : Le Bear CNC Forum | Addin : Airfoil Sketch from file
0 Likes