Tool Numbering Refresh Issue

Tool Numbering Refresh Issue

cfastM58RS
Advocate Advocate
1,514 Views
9 Replies
Message 1 of 10

Tool Numbering Refresh Issue

cfastM58RS
Advocate
Advocate

I know I have seen this posted before but I don't remember if it was here or on the Delcam Forum...

 

When tool numbers are assigned to the tools in the Powermill project, the numbers are not updated in the NC Program if it has already been posted.

 

Here is an example:

If I post a program for a VM, the tool numbers will start at 7 and increment up by 1.  Now lets say a different machine opens up and I am asked to re-post the program for the open machine that requires the tools to be numbered at 61 and up.  I have to re-open the powermill project and re-number the tools.  When the tools are re-numbered, they are not updated in the NC program.  The only way to get the tool numbers updated in the NC program is to shut down Powermill again and re-open the project.

 

 

I realize that I could write a macro to re-number the tools in the NC program itself, but I like numbering in the project so if the same tool is used in multiple NC programs it will have the same tool number.

 

 

Thanks,

Chris

0 Likes
1,515 Views
9 Replies
Replies (9)
Message 2 of 10

cfastM58RS
Advocate
Advocate

Does anyone know of a way around having to close and re-open Powermill? I would like to write a macro for renumbering the tools and re-posting.

0 Likes
Message 3 of 10

Anonymous
Not applicable

Answer1: This macro working without re-open PMill:

 

FUNCTION MAIN () {
// RENUMBER ALL TOOLS
   STRING LIST Choices={'7','61'}
   BOOL ERR = false
   INT I=INPUT CHOICE $Choices "Start number?"
   $ERR = ERROR $I
   IF NOT $ERR  {
      $I=int($Choices[$I])
      FOREACH $Tl IN folder('tool') {
         $TL.NUmber.Value=$I
         $I=$I+1
      }
      FOREACH $NC IN folder('ncprogram') {
         EDIT NCPROGRAM $NC.Name LOADTOOL ON
         EDIT NCPROGRAM $NC.Name RESET
      }
   }
}

 

 

Answer 2:

Start new Pmill - but not reopen project 😞

// Need a valid PMILL path

OLE FILEACTION "OPEN" "C:\Program Files\Autodesk\PowerMill 21.0.30\sys\exec64\pmill.exe"
EXIT NO

 

0 Likes
Message 4 of 10

cfastM58RS
Advocate
Advocate

I copied and pasted your macro and ran it.  It does the same thing as mine.  It will change the tool numbers in the NC programs as long as the NC program hasn't been posted in that instance of Powermill.

 

I think there is a bug in Powermill because this macro didn't even number all the tools in the project which it should have.

 

I am running Powermill 2017 SP5.

 

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

Modified  macro:

FUNCTION MAIN () {
// RENUMBER ALL TOOLS, then re-post all ncprogram
   STRING LIST Choices={'7','61'}
   BOOL ERR = false
   INT I=INPUT CHOICE $Choices "Start number?"
   $ERR = ERROR $I
   IF NOT $ERR  {
      $I=int($Choices[$I])
      FOREACH $Tl IN folder('tool') {
         $TL.Number.UserDefined=true
         $TL.NUmber.Value=$I
         $I=$I+1
      }
      FOREACH $NC IN folder('ncprogram') {
         EDIT NCPROGRAM $NC.Name LOADTOOL ON
         EDIT NCPROGRAM $NC.Name RESET
      }
      KEEP NCPROGRAM ALL YES
  }
}

0 Likes
Message 6 of 10

cfastM58RS
Advocate
Advocate

With that last addition the tools that were not getting numbered at all before now do have a number.  But the tool numbers are not updated in the posted NC programs.

 

 

Thanks for your input,

Chris

0 Likes
Message 7 of 10

Anonymous
Not applicable

Is the NC program active when you try to renumber  ?.

 

Also make sure Tool Numbering is set to As Specified if you want it to use the numbers as specified in the tools .

 

If NC program is active then, once you have renumbered your tools you could use the command :

 EDIT NCPROGRAM # RESET which is in the macro above as EDIT NCPROGRAM $NC.Name RESET

 

That will reset the tool numbers in the active NC program.

 

KEN

 

 

0 Likes
Message 8 of 10

Anonymous
Not applicable

Alternative solution: modify your second postprocessor for use Tool Number + 54.

 

Step 1. Parameters -> Tool ->Tool Number -> Allow Change =Yes

Step 2. Create script:

 

function OnBeforePostprocessing()
{
 for (i=1; i<=program.Tools.Count; i++) {
     if (program.Tools(i).GetParameter("%p(Tool Number)%") <7) {
        UserError("Tool number < 7");
     }
     program.Tools(i).SetParameter("%p(Tool Number)%",program.Tools(i).GetParameter("%p(Tool Number)%")+54);
  } 
}

Step 3.Click 'Script' -> Run Before Postprocessing -> OnBeforePostprocessing

OnBefore.JPG

 

See attached sample pp + cutfile.

 

Message 9 of 10

cfastM58RS
Advocate
Advocate

I believe there is a bug in Powermill with this issue.  I can have the NC program active and run the macro and click reset and the tool numbers still don't  change.  Again, this only occurs when you re-number tools in the project after the NC program has been posted in that same instance of Powermill.  I have accepted the fact that until Autodesk fixes this issue I will have to shut down Powermill and re-open the project to update the tool numbers.

0 Likes
Message 10 of 10

cfastM58RS
Advocate
Advocate

To tibor.vekasi,

 

That would be a creative solution but I don't want to edit posts for multiple machines to fix a what appears to be a bug in Powermill.  Doing this I would also have to change my tool lists that are generated by Powermill.

 

I'll give a kudos anyways for thinking outside of the box!

0 Likes