please help with macro

please help with macro

romanov-kovrov
Explorer Explorer
257 Views
4 Replies
Message 1 of 5

please help with macro

romanov-kovrov
Explorer
Explorer

FOREACH tp IN folder('Toolpath') {
ACTIVATE TOOLPATH $tp.Name
STRING NewName = replace(Name, 'DRAFT', 'FINAL')+'...'+limits('toolpath','')[4]
RENAME TOOLPATH ; $NewName
}

 

1.help me modify it to round or leave 2 digits after the point like 0.00

image.png

 

2. tell me a macro to rename all Toolpaths at once, delete everything to the right of ... dots, thanks

0 Likes
258 Views
4 Replies
Replies (4)
Message 2 of 5

iamcdn79
Mentor
Mentor

This rounds to 2 decimal places.

 

FOREACH tp IN folder('Toolpath') {
    ACTIVATE TOOLPATH $tp.Name

    REAL zVal = round(limits('toolpath','')[4]; 2)

    STRING NewName = replace(Name, 'DRAFT', 'FINAL') + '...' + $zVal
    RENAME TOOLPATH ; $NewName
}

 

I don't understand your renaming request. you want to delete  the z min limits that were added to your toolpath name? Thats what is to the right of the dots.


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
Message 3 of 5

romanov-kovrov
Explorer
Explorer

yes, you understood everything correctly, before you write to delete the values, if I recalculate TOOLPATH and run the macro again it turns out like this, which can be confusingimage.png

0 Likes
Message 4 of 5

iamcdn79
Mentor
Mentor
FOREACH tp IN folder('Toolpath') {
    ACTIVATE TOOLPATH $tp.Name
    REAL zVal = round(limits('toolpath','')[4]; 2)
    
    STRING baseName = replace(Name, 'DRAFT', 'FINAL')
    
    // Remove any existing "...zVal" value from previous runs
    INT lastDotPos = position($baseName, '...')
    IF lastDotPos > 0 {
        $baseName = substring($baseName, 0, lastDotPos)
    }
    
    STRING NewName = $baseName + '...' + $zVal
    RENAME TOOLPATH ; $NewName
}

Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
Message 5 of 5

romanov-kovrov
Explorer
Explorer

Thank you so much! Everything worked as I wanted.

0 Likes