Sort toolpaths by workplane position or boundary

Sort toolpaths by workplane position or boundary

Sean570
Advocate Advocate
768 Views
3 Replies
Message 1 of 4

Sort toolpaths by workplane position or boundary

Sean570
Advocate
Advocate

So I have a macro that I use to split up a toolpath folder of drilling paths using the active boundary and keeps both paths. Is there a way to sort the resulting paths into separate folders, depending on if they were inside or outside of the boundary? Also, I'm using powermill 2015.

 

 

 

 

   GRAPHICS LOCK
    DIALOGS MESSAGE OFF 

    STRING activeBoundary = ""
    IF ENTITY_EXISTS(ENTITY('BOUNDARY', '')) {
        $activeBoundary =  ENTITY('BOUNDARY', '').Name
    } ELSE {
        MACRO PAUSE "Activate a boundary!"
    }

    STRING fld = active_folder()
    IF POSITION($fld, "Toolpath") == -1 {
        GRAPHICS UNLOCK
        MACRO PAUSE "Please activate a toolpath folder"
        GRAPHICS LOCK
        $fld = active_folder()
    }
    FOREACH tp IN folder($fld){        
        ACTIVATE TOOLPATH $tp.name
        EDIT TOOLPATH LIMIT BOUNDARY
        EDIT TOOLPATH LIMIT BOUNDARYNAME $activeBoundary
        EDIT TOOLPATH LIMIT DELETE Y
        EDIT TOOLPATH LIMIT BOUNDPLANEOPTIONS ACTIVE_WORKPLANE
        EDIT TOOLPATH LIMIT KEEP BOTH
        PROCESS TPLIMIT
    }
    
    GRAPHICS UNLOCK
    DIALOGS MESSAGE ON

 

 

 

 


If I can't use the boundary itself, using the workplane coordinates to sort them would be the next best option. Since most of the toolpaths I am splitting are drilling toolpaths, I can't use boundaries while calculating them either. Any thoughts?

0 Likes
769 Views
3 Replies
Replies (3)
Message 2 of 4

cfastNJWK6
Advisor
Advisor

When the toolpath is split using a boundary, a new toolpath is created.  That toolpath name should be recognized by the new_entity_name() function.

 

 

    FOREACH tp IN folder($fld){        
        ACTIVATE TOOLPATH $tp.name
        EDIT TOOLPATH LIMIT BOUNDARY
        EDIT TOOLPATH LIMIT BOUNDARYNAME $activeBoundary
        EDIT TOOLPATH LIMIT DELETE Y
        EDIT TOOLPATH LIMIT BOUNDPLANEOPTIONS ACTIVE_WORKPLANE
        EDIT TOOLPATH LIMIT KEEP BOTH
        PROCESS TPLIMIT
        //get the new toolpath name
        STRING $NewTpName = new_entity_name('toolpath', $tp.name)
        //put new toolpath into different folder
        EDIT FOLDER "Toolpath\Folder1" INSERT $NewTpName
        
    }

 

 

You should also add to the macro to either save the inner or outer portion.  That should guarantee which side of the boundary the new toolpath will be on.

0 Likes
Message 3 of 4

artur.boszczyk
Advocate
Advocate

Thanks for sharing @cfastNJWK6 . Few things to make it work:

 

STRING $NewTpName = new_entity_name('toolpath', $tp.name) // do first before PROCESS TPLIMIT
PROCESS TPLIMIT

EDIT FOLDER $folderName INSERT $NewTpName LAST //put new toolpath into different folder

 

I would also add folder creation as it may not exist

 

STRING folderName="Toolpath\" + $activeBoundary

IF NOT folder_exists($folderName) {
CREATE FOLDER "Toolpath" $activeBoundary
}

0 Likes
Message 4 of 4

artur.boszczyk
Advocate
Advocate

Thanks for sharing @cfastNJWK6 . Few things to make it work:

 

STRING $NewTpName = new_entity_name('toolpath', $tp.name) // do first before PROCESS TPLIMIT
PROCESS TPLIMIT

EDIT FOLDER $folderName INSERT $NewTpName LAST //put new toolpath into different folder

 

I would also add folder creation as it may not exist

 

STRING folderName="Toolpath\" + $activeBoundary

IF NOT folder_exists($folderName) {
CREATE FOLDER "Toolpath" $activeBoundary
}

 

Cheers

0 Likes