Macro to Auto adjust Overhang, using holder profile

Macro to Auto adjust Overhang, using holder profile

Sean570
Advocate Advocate
1,121 Views
3 Replies
Message 1 of 4

Macro to Auto adjust Overhang, using holder profile

Sean570
Advocate
Advocate

I've got a macro that will calculate the holder profile for all tools being used. The issue I have is when I add a line of code auto adjust the overhang based on the holder profile. It works just fine, until it comes across a locked tools. So I have been trying to get something to detect that the tool is locked, and if so, not calculate the overhang.

I have used ERROR DOCOMMAND in the past to catch things like this, but I can't seem to get the syntax right for DOCOMMAND to work properly. I am using powermill 2015 
Here's what I have, any ideas would be appreciated: 

ENTITY LIST usedTools = {} 
$usedTools = extract(folder('toolpath'), 'tool')
INT Duplicates = 0
$Duplicates = remove_duplicates($usedTools) 


FOREACH tool IN $usedTools {
    EDIT TOOL $tool PROFILE_INCLUDE_ALL
    EDIT TOOL $tool UPDATE_TOOLPATHS_PROFILE  
    BOOL error = 0
    STRING toolName = $tool.name 
    STRING cmd = "EDIT TOOL" + $toolName + "AUTO_OVERHANG"
    $error = ERROR DOCOMMAND $cmd
    IF NOT $error {
       EDIT TOOL $toolName AUTO_OVERHANG
   } 
}

 

0 Likes
Accepted solutions (1)
1,122 Views
3 Replies
Replies (3)
Message 2 of 4

mark.sully
Autodesk
Autodesk
Accepted solution

Try this:

ENTITY LIST usedTools = extract(folder('toolpath'), 'tool')
INT Duplicates = remove_duplicates($usedTools) 

FOREACH t IN $usedTools {
  EDIT TOOL $t.Name PROFILE_INCLUDE_ALL
  EDIT TOOL $t.Name UPDATE_TOOLPATHS_PROFILE
  IF NOT locked($t.Diameter) {
    EDIT TOOL $t.Name AUTO_OVERHANG
  } 
}

 

The locked() function checks if a parameter is locked (tool diameter is a good check if a tool is locked).

 

Hope this helps.

Mark

 

PS. I also changed your variable name in the loop from 'tool' to 't' as it isn't good practice to use variables with the same name as PowerMill entities.

Message 3 of 4

Sean570
Advocate
Advocate

Thanks! That works perfectly. I searched through the parameters/functions many times but it seems I missed that one. I just adjusted the macro to check if the overhang is locked instead of the diameter.

ENTITY LIST usedTools = {} 
  $usedTools = extract(folder('toolpath'), 'tool')
  INT Duplicates = 0
  $Duplicates = remove_duplicates($usedTools) 

    FOREACH tl IN $usedTools {
    EDIT TOOL $tl.Name PROFILE_INCLUDE_ALL
    EDIT TOOL $tl.Name UPDATE_TOOLPATHS_PROFILE
    IF NOT locked($tl.Overhang) {
      EDIT TOOL $tl.Name AUTO_OVERHANG
    } 
  }
Message 4 of 4

mayankpatel5523
Explorer
Explorer

Please, create this macro for single toolpath

0 Likes