Refresh/Update Toolpath name

Refresh/Update Toolpath name

evo80
Collaborator Collaborator
1,332 Views
7 Replies
Message 1 of 8

Refresh/Update Toolpath name

evo80
Collaborator
Collaborator

Good Day,

I have this macro which will number and add toolpath info.

Once I have this, perhaps I might edit the name somewhat, replace the tool etc.

What I was wondering is if there's a way to refresh selected toolpaths, keeping the toolpath number but refreshing the tool info? 

 

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 { reset localvars string $new_name = "" STRING Strategy = 'null' DIALOGS MESSAGE OFF DIALOGS ERROR OFF GRAPHICS LOCK //starting number INT StartNumber = INPUT "Start at #?" INT start = $StartNumber STRING start1 = $StartNumber INT i = $start1 //set text to replace and new text STRING oldText = "." STRING newText = "," // IF { // Commands A // } ELSEIF { // Commands B // } ELSE { // Commands C // } FOREACH $tp IN explorer_selected_entities() { IF tp.drill.type == "helical" { //RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number} RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_XY" + tp.Drill.Thickness + "_Z" + tp.Drill.AxialThickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF tp.drill.type == "thread_mill" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_XY" + tp.Drill.Thickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "drill" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF tp.drill.type == "deep_drill" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF tp.drill.type == "break_chip" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "swarf" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "surface_machine" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "curve_profile" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "chamfer" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number} $i = $i + 1 } ELSEIF $tp.Strategy == "curve_area_clear" { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number} $i = $i + 1 } ELSE { RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number} $i = $i + 1 } IF position(tp.name, oldText) >= 0 { STRING newName = replace(tp.name, oldText, newText) RENAME TOOLPATH $tp.name $newName STRING newName2 = replace(tp.name, "chamfer", "Chamf") RENAME TOOLPATH $tp.name $newName2 STRING newName3 = replace(tp.name, "curve_profile", "Crv-Prof") RENAME TOOLPATH $tp.name $newName3 STRING newName4 = replace(tp.name, "adaptive_area_clear", "Vort-AreaClear") RENAME TOOLPATH $tp.name $newName4 STRING newName5 = replace(tp.name, "surface_machine", "SurfMachine") RENAME TOOLPATH $tp.name $newName5 STRING newName6 = replace(tp.name, "offset_area_clear", "Off-AreaClear") RENAME TOOLPATH $tp.name $newName6 STRING newName7 = replace(tp.name, "drill", "Drill") RENAME TOOLPATH $tp.name $newName7 STRING newName8 = replace(tp.name, "swarf", "Swarf") RENAME TOOLPATH $tp.name $newName8 STRING newName9 = replace(tp.name, "pattern", "Pattern") RENAME TOOLPATH $tp.name $newName9 STRING newName10 = replace(tp.name, "curve_area_clear", "Crv-AreaClear") RENAME TOOLPATH $tp.name $newName10 STRING newName11 = replace(tp.name, "face", "Face") RENAME TOOLPATH $tp.name $newName11 STRING newName12 = replace(tp.name, "embedded", "Embed") RENAME TOOLPATH $tp.name $newName12 STRING newName13 = replace(tp.name, "offset_flat", "Off-Flat") RENAME TOOLPATH $tp.name $newName13 STRING newName14 = replace(tp.name, "offset_3d", "Off-3d") RENAME TOOLPATH $tp.name $newName14 STRING newName15 = replace(tp.name, "constantz", "Const-Z") RENAME TOOLPATH $tp.name $newName15 STRING newName16 = replace(tp.name, "automatic_corner", "AutoCorn") RENAME TOOLPATH $tp.name $newName16 STRING newName17 = replace(tp.name, "multi_pencil_corner", "MultiPen") RENAME TOOLPATH $tp.name $newName17 STRING newName18 = replace(tp.name, "pencil_corner", "Pencil") RENAME TOOLPATH $tp.name $newName18 STRING newName19 = replace(tp.name, "disc_profile", "DiscProf") RENAME TOOLPATH $tp.name $newName19 STRING newName20 = replace(tp.name, "flowline", "Flow") RENAME TOOLPATH $tp.name $newName20 STRING newName21 = replace(tp.name, "opti_constz", "OptiConstZ") RENAME TOOLPATH $tp.name $newName21 STRING newName22 = replace(tp.name, "parametric_offset", "ParaOffset") RENAME TOOLPATH $tp.name $newName22 STRING newName23 = replace(tp.name, "parametric_spiral", "ParaSpiral") RENAME TOOLPATH $tp.name $newName23 STRING newName24 = replace(tp.name, "profile", "Prof") RENAME TOOLPATH $tp.name $newName24 STRING newName25 = replace(tp.name, "curve_projection", "Crv-Proj") RENAME TOOLPATH $tp.name $newName25 STRING newName26 = replace(tp.name, "line_projection", "LineProj") RENAME TOOLPATH $tp.name $newName26 STRING newName27 = replace(tp.name, "plane_projection", "PlaneProj") RENAME TOOLPATH $tp.name $newName27 STRING newName28 = replace(tp.name, "point_projection", "PointProj") RENAME TOOLPATH $tp.name $newName28 STRING newName29 = replace(tp.name, "surFace_proj", "Surf-Proj") RENAME TOOLPATH $tp.name $newName29 STRING newName30 = replace(tp.name, "radial", "Radial") RENAME TOOLPATH $tp.name $newName30 STRING newName31 = replace(tp.name, "raster", "Raster") RENAME TOOLPATH $tp.name $newName31 STRING newName32 = replace(tp.name, "Raster_flat", "Rast-Flat") RENAME TOOLPATH $tp.name $newName32 STRING newName33 = replace(tp.name, "rest_finishing", "RestFinish") RENAME TOOLPATH $tp.name $newName33 STRING newName34 = replace(tp.name, "rotary", "Rotary") RENAME TOOLPATH $tp.name $newName34 STRING newName35 = replace(tp.name, "spiral", "Spiral") RENAME TOOLPATH $tp.name $newName35 STRING newName36 = replace(tp.name, "inter_constz", "SteepShallow") RENAME TOOLPATH $tp.name $newName36 STRING newName37 = replace(tp.name, "wireframe_Profile", "WireProf") RENAME TOOLPATH $tp.name $newName37 STRING newName38 = replace(tp.name, "wireframe_Swarf", "WireSwarf") RENAME TOOLPATH $tp.name $newName38 STRING newName39 = replace(tp.name, "bore_1", "Ream") RENAME TOOLPATH $tp.name $newName39 STRING newName40 = replace(tp.name, "tap_2", "RigidTap") RENAME TOOLPATH $tp.name $newName40 STRING newName41 = replace(tp.name, "single_peck", "Sing-Peck") RENAME TOOLPATH $tp.name $newName41 STRING newName42 = replace(tp.name, "helical", "Heli") RENAME TOOLPATH $tp.name $newName42 STRING newName43 = replace(tp.name, "break_chip", "Universal") RENAME TOOLPATH $tp.name $newName43 STRING newName44 = replace(tp.name, "deep_Drill", "DeepDrill") RENAME TOOLPATH $tp.name $newName44 STRING newName45 = replace(tp.name, "Raster_area_clear", "Rast-AreaClear") RENAME TOOLPATH $tp.name $newName45 STRING newName46 = replace(tp.name, "corner_clear", "CornerClear") RENAME TOOLPATH $tp.name $newName46 STRING newName47 = replace(tp.name, "Profile_area_clear", "ProfAreaClear") RENAME TOOLPATH $tp.name $newName47 STRING newName48 = replace(tp.name, "plunge", "Plunge") RENAME TOOLPATH $tp.name $newName48 STRING newName49 = replace(tp.name, "Drill_thread_mill", "ThreadMill") RENAME TOOLPATH $tp.name $newName49 STRING newName50 = replace(tp.name, "port_area_clear", "PortAreaClear") RENAME TOOLPATH $tp.name $newName50 STRING newName51 = replace(tp.name, "port_Plunge", "PortPlunge") RENAME TOOLPATH $tp.name $newName51 STRING newName52 = replace(tp.name, "port_Spiral", "PortSpiral") RENAME TOOLPATH $tp.name $newName52 STRING newName53 = replace(tp.name, "surFace_inspection", "Probing") RENAME TOOLPATH $tp.name $newName53 DEACTIVATE Toolpath DEACTIVATE TOOL UNDRAW TOOL ALL } } DIALOGS MESSAGE ON DIALOGS ERROR ON GRAPHICS UNLOCK

0 Likes
Accepted solutions (1)
1,333 Views
7 Replies
Replies (7)
Message 2 of 8

evo80
Collaborator
Collaborator

Try that again,

 

IF $powermill.Status.MultipleSelection.First OR $powermill.Status.MultipleSelection.Total == 0 {
reset localvars
string $new_name = ""
STRING Strategy = 'null'

DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
GRAPHICS LOCK


//starting number
INT StartNumber = INPUT "Start at #?"
INT start = $StartNumber
STRING start1 = $StartNumber
INT i = $start1


//set text to replace and new text
STRING oldText = "."
STRING newText = ","


// IF <expression_1> {
// Commands A
// } ELSEIF <expression_2> {
// Commands B
// } ELSE {
// Commands C
// }

 

FOREACH $tp IN explorer_selected_entities() {

IF tp.drill.type == "helical" {

//RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number}
RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_XY" + tp.Drill.Thickness + "_Z" + tp.Drill.AxialThickness + "_T" + tp.tool.number}

$i = $i + 1

} ELSEIF tp.drill.type == "thread_mill" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_XY" + tp.Drill.Thickness + "_T" + tp.tool.number}

$i = $i + 1


} ELSEIF $tp.Strategy == "drill" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number}

$i = $i + 1


} ELSEIF tp.drill.type == "deep_drill" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number}

$i = $i + 1


} ELSEIF tp.drill.type == "break_chip" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.drill.type + "_" + tp.Tool.Identifier + "_T" + tp.tool.number}

$i = $i + 1

} ELSEIF $tp.Strategy == "swarf" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number}

$i = $i + 1


} ELSEIF $tp.Strategy == "surface_machine" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number}

$i = $i + 1

 

} ELSEIF $tp.Strategy == "curve_profile" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number}

$i = $i + 1


} ELSEIF $tp.Strategy == "chamfer" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number}

$i = $i + 1

 

} ELSEIF $tp.Strategy == "curve_area_clear" {

RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.CurveThickness + "_T" + tp.tool.number}

$i = $i + 1

 

} ELSE {
RENAME TOOLPATH $tp.Name ${i + "_" + tp.Strategy + "_" + tp.Tool.Identifier + "_XY" + tp.Thickness + "_Z" + tp.axial_thickness + "_T" + tp.tool.number}

$i = $i + 1
}

IF position(tp.name, oldText) >= 0 {
STRING newName = replace(tp.name, oldText, newText)
RENAME TOOLPATH $tp.name $newName
STRING newName2 = replace(tp.name, "chamfer", "Chamf")
RENAME TOOLPATH $tp.name $newName2
STRING newName3 = replace(tp.name, "curve_profile", "Crv-Prof")
RENAME TOOLPATH $tp.name $newName3
STRING newName4 = replace(tp.name, "adaptive_area_clear", "Vort-AreaClear")
RENAME TOOLPATH $tp.name $newName4
STRING newName5 = replace(tp.name, "surface_machine", "SurfMachine")
RENAME TOOLPATH $tp.name $newName5
STRING newName6 = replace(tp.name, "offset_area_clear", "Off-AreaClear")
RENAME TOOLPATH $tp.name $newName6
STRING newName7 = replace(tp.name, "drill", "Drill")
RENAME TOOLPATH $tp.name $newName7
STRING newName8 = replace(tp.name, "swarf", "Swarf")
RENAME TOOLPATH $tp.name $newName8
STRING newName9 = replace(tp.name, "pattern", "Pattern")
RENAME TOOLPATH $tp.name $newName9
STRING newName10 = replace(tp.name, "curve_area_clear", "Crv-AreaClear")
RENAME TOOLPATH $tp.name $newName10
STRING newName11 = replace(tp.name, "face", "Face")
RENAME TOOLPATH $tp.name $newName11
STRING newName12 = replace(tp.name, "embedded", "Embed")
RENAME TOOLPATH $tp.name $newName12
STRING newName13 = replace(tp.name, "offset_flat", "Off-Flat")
RENAME TOOLPATH $tp.name $newName13
STRING newName14 = replace(tp.name, "offset_3d", "Off-3d")
RENAME TOOLPATH $tp.name $newName14
STRING newName15 = replace(tp.name, "constantz", "Const-Z")
RENAME TOOLPATH $tp.name $newName15
STRING newName16 = replace(tp.name, "automatic_corner", "AutoCorn")
RENAME TOOLPATH $tp.name $newName16
STRING newName17 = replace(tp.name, "multi_pencil_corner", "MultiPen")
RENAME TOOLPATH $tp.name $newName17
STRING newName18 = replace(tp.name, "pencil_corner", "Pencil")
RENAME TOOLPATH $tp.name $newName18
STRING newName19 = replace(tp.name, "disc_profile", "DiscProf")
RENAME TOOLPATH $tp.name $newName19
STRING newName20 = replace(tp.name, "flowline", "Flow")
RENAME TOOLPATH $tp.name $newName20
STRING newName21 = replace(tp.name, "opti_constz", "OptiConstZ")
RENAME TOOLPATH $tp.name $newName21
STRING newName22 = replace(tp.name, "parametric_offset", "ParaOffset")
RENAME TOOLPATH $tp.name $newName22
STRING newName23 = replace(tp.name, "parametric_spiral", "ParaSpiral")
RENAME TOOLPATH $tp.name $newName23
STRING newName24 = replace(tp.name, "profile", "Prof")
RENAME TOOLPATH $tp.name $newName24
STRING newName25 = replace(tp.name, "curve_projection", "Crv-Proj")
RENAME TOOLPATH $tp.name $newName25
STRING newName26 = replace(tp.name, "line_projection", "LineProj")
RENAME TOOLPATH $tp.name $newName26
STRING newName27 = replace(tp.name, "plane_projection", "PlaneProj")
RENAME TOOLPATH $tp.name $newName27
STRING newName28 = replace(tp.name, "point_projection", "PointProj")
RENAME TOOLPATH $tp.name $newName28
STRING newName29 = replace(tp.name, "surFace_proj", "Surf-Proj")
RENAME TOOLPATH $tp.name $newName29
STRING newName30 = replace(tp.name, "radial", "Radial")
RENAME TOOLPATH $tp.name $newName30
STRING newName31 = replace(tp.name, "raster", "Raster")
RENAME TOOLPATH $tp.name $newName31
STRING newName32 = replace(tp.name, "Raster_flat", "Rast-Flat")
RENAME TOOLPATH $tp.name $newName32
STRING newName33 = replace(tp.name, "rest_finishing", "RestFinish")
RENAME TOOLPATH $tp.name $newName33
STRING newName34 = replace(tp.name, "rotary", "Rotary")
RENAME TOOLPATH $tp.name $newName34
STRING newName35 = replace(tp.name, "spiral", "Spiral")
RENAME TOOLPATH $tp.name $newName35
STRING newName36 = replace(tp.name, "inter_constz", "SteepShallow")
RENAME TOOLPATH $tp.name $newName36
STRING newName37 = replace(tp.name, "wireframe_Profile", "WireProf")
RENAME TOOLPATH $tp.name $newName37
STRING newName38 = replace(tp.name, "wireframe_Swarf", "WireSwarf")
RENAME TOOLPATH $tp.name $newName38
STRING newName39 = replace(tp.name, "bore_1", "Ream")
RENAME TOOLPATH $tp.name $newName39
STRING newName40 = replace(tp.name, "tap_2", "RigidTap")
RENAME TOOLPATH $tp.name $newName40
STRING newName41 = replace(tp.name, "single_peck", "Sing-Peck")
RENAME TOOLPATH $tp.name $newName41
STRING newName42 = replace(tp.name, "helical", "Heli")
RENAME TOOLPATH $tp.name $newName42
STRING newName43 = replace(tp.name, "break_chip", "Universal")
RENAME TOOLPATH $tp.name $newName43
STRING newName44 = replace(tp.name, "deep_Drill", "DeepDrill")
RENAME TOOLPATH $tp.name $newName44
STRING newName45 = replace(tp.name, "Raster_area_clear", "Rast-AreaClear")
RENAME TOOLPATH $tp.name $newName45
STRING newName46 = replace(tp.name, "corner_clear", "CornerClear")
RENAME TOOLPATH $tp.name $newName46
STRING newName47 = replace(tp.name, "Profile_area_clear", "ProfAreaClear")
RENAME TOOLPATH $tp.name $newName47
STRING newName48 = replace(tp.name, "plunge", "Plunge")
RENAME TOOLPATH $tp.name $newName48
STRING newName49 = replace(tp.name, "Drill_thread_mill", "ThreadMill")
RENAME TOOLPATH $tp.name $newName49
STRING newName50 = replace(tp.name, "port_area_clear", "PortAreaClear")
RENAME TOOLPATH $tp.name $newName50
STRING newName51 = replace(tp.name, "port_Plunge", "PortPlunge")
RENAME TOOLPATH $tp.name $newName51
STRING newName52 = replace(tp.name, "port_Spiral", "PortSpiral")
RENAME TOOLPATH $tp.name $newName52
STRING newName53 = replace(tp.name, "surFace_inspection", "Probing")
RENAME TOOLPATH $tp.name $newName53


DEACTIVATE Toolpath
DEACTIVATE TOOL
UNDRAW TOOL ALL
}
}

DIALOGS MESSAGE ON
DIALOGS ERROR ON
GRAPHICS UNLOCK

 

0 Likes
Message 3 of 8

TK.421
Advisor
Advisor

deactivate/reactivate the toolpath, that'll refresh the info


the numbers never lie
0 Likes
Message 4 of 8

evo80
Collaborator
Collaborator

Maybe I should explain a bit better.

I have a bunch of toolpaths (Pic1).

I run the macro (Pic2).

Now say for instance I change the tool used and thickness for a certain toolpath.

I want to create a macro button in my quick access toolbar (or user menu) which will update/refresh any selected toolpaths, returning the original toolpath number and any text edits made to the toolpath strategy.

So in short only the tool used, toolpath thickness and the tool number should be refreshed.

I hope that makes sense.

 

 

 

 

 

0 Likes
Message 5 of 8

TK.421
Advisor
Advisor

so you want it to store the original information before you change, and then be able to recall it later?

 

the only way i can think to do that is to create a user defined parameter in the toolpath prior to changing it your first macro.


the numbers never lie
0 Likes
Message 6 of 8

evo80
Collaborator
Collaborator

@TK.421 Yes, that's exactly what I want.

Just not sure how to do that.

Thanks for the input btw!

0 Likes
Message 7 of 8

TK.421
Advisor
Advisor
Accepted solution

Capture.PNG

 

try this code:

// for a string value
EDIT USERPAR toolpath_strategy ; TYPE 'String'
EDIT USERPAR toolpath_strategy ; NAME "stringName"
CREATE USERPAR toolpath_strategy ;
EDIT USERPAR toolpath_strategy ; "stringName" 'stringValue'

// for a real value
EDIT USERPAR toolpath_strategy ; TYPE 'Real'
EDIT USERPAR toolpath_strategy ; NAME "realName"
CREATE USERPAR toolpath_strategy ;
EDIT USERPAR toolpath_strategy ; "realName" '3.14'

 

then recall it thusly:

ENTITY activeToolpath = entity('toolpath','')

If member($activeToolpath.UserParameters._keys, "stringName") {
    STRING msg = $activeToolpath.UserParameters.stringName
    MESSAGE INFO $msg
}

 


the numbers never lie
0 Likes
Message 8 of 8

evo80
Collaborator
Collaborator

Thanks Mate,

I'll have a fiddle with that code.

Regards Jon K

0 Likes