Community
Fusion Manufacture
Talk shop with the Fusion (formerly Fusion 360) Manufacture Community. Share tool strategies, tips, get advice and solve problems together with the best minds in the industry.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to insert the total Machining Time into a comment in the G-Code output

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
bryn7NWJL
722 Views, 6 Replies

How to insert the total Machining Time into a comment in the G-Code output

Is this possible?  Searched a while, but not finding anything on this topic on the web.  When I post Process from Fusion to Mach3, I'd like the sum of the selected tool paths' runtimes to be inserted into the header (in a comment) of the NC file.  Then, I plan to have Mach3 somehow read that number and give me a count-down timer when I run the job.

 

Anyone done anything like this already to save me the trouble of re-inventing the wheel?

 

 

Labels (1)
6 REPLIES 6
Message 2 of 7

@bryn7NWJL 

Currently there is no parameter which will directly fetch you the machining time but you can add some codes to get the machine time.

you can use this function to calculate the machining time

function getMachiningTime(){
  var rapidDistance = 0;
  var cycleTime = properties.toolChangeTime;
  var numberOfSections = getNumberOfSections();
  for (var i = 0; i < numberOfSections; ++i) {
    var section = getSection(i);
    var tool = section.getTool();
    cycleTime += section.getCycleTime();
    rapidDistance += section.getRapidDistance();
    
    if(i !=0 && getSection(i-1).getTool().number != tool.number){
      cycleTime += properties.toolChangeTime;
    }
  }
  if (properties.rapidFeed > 0) {
    cycleTime += rapidDistance / properties.rapidFeed*60;
  }
  writeComment("Machining Time = " + cycleTime.toFixed(0) + " Sec");
}

 Also two properties needs to be added to get this function work

in the properties section you have add this 

  useRigidTapping: "yes", // output rigid tapping block
//<<<Add this below two line >> don't forgot to put , at the end of "yes"
  rapidFeed: 5000, // the rapid traversal feed
  toolChangeTime: 15 // the time in seconds for a tool change
};

and in the properties Definition

      {title:"Without spindle direction", id:"without"}
    ]
  },
//<<<Add this below two line >> don't forgot to put , at the end of previous block

  rapidFeed: {title:"Rapid feed", description:"Sets the rapid traversal feedrate. Set this to get more accurate cycle times.",group:0, type:"number"},
  toolChangeTime: {title:"Tool change time", description:"Sets the tool change time in seconds. Set this to get more accurate cycle times.",group:0, type:"number"}

};

var permittedCommentChars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,=_-";

 

and call the getMachiningTime function inside the onOpen section

  }
  getMachiningTime();   //<< Add to Print the Machining time

  // dump tool information
  if (properties.writeTools) {
    var zRanges = {};
    if (is3D()) {

 


Boopathi Sivakumar
Senior Technology Consultant

Message 3 of 7

Worked Perfectly.  Thank you.   I now get the comment for total machine time in my NC output.  Exactly as I wanted.

I'll post an update here again once I work out the second-half of these solution;  to get Mach3 to pull that number from the .tap (nc) file and create a countdown timer for the full job run.

Message 4 of 7
bryn7NWJL
in reply to: bryn7NWJL

Here's the rest of the solution on the Mach3 side:

Theory of operation:  Grab the total run-time seconds from the NC file (xxxx.tap in this case for Mach3 NC files) put there by the Fusion 360 post process and display it on the screen so the operator knows how long this job will take.

 

1.)  Under General Config in Mach3, be sure the option "Ignore M calls while loading" is Unchecked.

2.)  Create a macro file (I used 1050.m1s) in the C:\mach3\macros\<your profile> folder.  

3.)  In that file, place this code:

InSeconds = param3()  'get the seconds passed as a R parameter from the M1050 line in the Fusion NC output
        seconds = inSeconds Mod 60
        inSeconds = (inSeconds - seconds) / 60
        'Dim minutes As Integer
        minutes = inSeconds Mod 60
        inSeconds = (inSeconds - minutes) / 60
        'Dim hours As Integer
        hours = inSeconds Mod 24
        inSeconds = (inSeconds - hours) / 24
        
        uptimeToHMS = hours & " Hr. " _
            & minutes & "Min. " _
            & seconds & "Sec."
SetUserLabel (1, uptimeToHMS) 
Message ("This program will take " & hours & " hours, " & minutes & " minutes, " & seconds & " seconds to run." )

4.)  Download a mach3 screen set editor (eg. Screen4.exe) from the Mach3 website.

5.) Create a new LABEL and place it on a screen where you want it.  IMPORTANT - Be sure the Label Text of that Label is "UserLabel1"

6.)  Save your screen set changes and launch Mach3.

7.)  You'll also need to modify the code provided in the Autodesk solution above so that the text placed in the NC file isn't actually a comment, but rather, "M1050 Rxxxxxx", where xxxxxx is their calculated runtime seconds.  NOTE to do this, you'll call their "writeBlock" function rather than "writeComment" so that you don't also put your text in Parentheses.

8.)  Now load your Fusion-exported NC file created by the post processor template with all the changes above.  Mach3 will process the M1050 macro script on loading and place the Hours, Minutes, Seconds on the Mach3 screen!  Done!

 

NOTE:  I realize Mach3 can also calculate an Estimate Time when you do a simulation.  However, it was extra work to wait for on another screen that you have to do, and I generally just skipped doing it because I didn't want to wait.   Now, job run-times are displayed instantly upon loading the file.

 

Next step (which might need the macropump function?) is to have a real-time count down or Percent Complete bar updating on the screen, but I haven't figured that one out yet.  For now, this is what I needed.

 

 

 

 

Message 5 of 7
constantin3x
in reply to: bryn7NWJL

@boopathi.sivakumar 

On your solution, you mention to add the following lines on the properties section

  useRigidTapping: "yes", // output rigid tapping block
//<<<Add this below two line >> don't forgot to put , at the end of "yes"
  rapidFeed: 5000, // the rapid traversal feed
  toolChangeTime: 15 // the time in seconds for a tool change
};

but it is not clear where that section is because under the user properties section we enter the definitions that you mention but where do we set these default values? I've included my haas post that I am trying to edit

 

 

Message 6 of 7

Hi @constantin3x 

It is a old method of defining properties now it has been changed

the code should look like the following 

  programmableCoolant: {
    title      : "Programmable coolant",
    description: "Enable if the machine has the programmable coolant option and requires the coolant to be enabled after tool length compensation is enabled.",
    group      : "preferences",
    type       : "boolean",
    value      : false,
    scope      : "post"
  },
  rapidFeed: {
    title      : "Rapid feed",
    description: "Sets the rapid traversal feedrate. Set this to get more accurate cycle times.",
    type       : "number",
    value      : 5000,
    scope      : "post"
  },
  toolChangeTime: {
    title      : "Tool change time",
    description: "Sets the tool change time in seconds. Set this to get more accurate cycle times.",
    type       : "number",
    value      : 15,
    scope      : "post"
  }
};

.

Also the function should be like this

 

function getMachiningTime() {
  var rapidDistance = 0;
  var cycleTime = getProperty("toolChangeTime");
  var numberOfSections = getNumberOfSections();
  for (var i = 0; i < numberOfSections; ++i) {
    var section = getSection(i);
    var tool = section.getTool();
    cycleTime += section.getCycleTime();
    rapidDistance += section.getRapidDistance();

    if (i != 0 && getSection(i - 1).getTool().number != tool.number) {
      cycleTime += getProperty("toolChangeTime");
    }
  }
  if (getProperty("rapidFeed") > 0) {
    cycleTime += rapidDistance / getProperty("rapidFeed") * 60;
  }
  writeComment("Machining Time = " + cycleTime.toFixed(0) + " Sec");
}

 


Boopathi Sivakumar
Senior Technology Consultant

Message 7 of 7

Hi Boopathi,

Anytime soon will this be added to default post-processor?

Thanks
Gokul Kannan
Making Parts at MetalRipper using Fusion 360
Youtube.com/@metalripper-
CNCexpert.com/gokul-kannan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums