project saving macro

project saving macro

g_borri
Participant Participant
587 Views
4 Replies
Message 1 of 5

project saving macro

g_borri
Participant
Participant

Hi everyone
I need your help to create a macro to save the powermill project.
in particular you should take the first 8 characters of the name of the imported model and use them to save the powermill project with a name.
my interest is that the macro works like the "save" command when first saving the powermill project.
with the same macro I would also like to create the NC program with the same name as the powermill project.
Can something like this be achieved?

Thanks for your help

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

icse
Advisor
Advisor

Where do you want to save the Powermill project? Is it always the same path?

0 Likes
Message 3 of 5

g_borri
Participant
Participant

Yes, it's always the same path. "C:\Users\Andrea\Desktop"

0 Likes
Message 4 of 5

icse
Advisor
Advisor

try this:

 

 

 

 

 

string $path = "C:\Users\Andrea\Desktop"

if not dir_exists($path) {
	message info "path does not exists"
	return
}

string $modelName = folder('model')[0].Name

if length($modelName) < 8 {
	return
}

if not entity_exists('ncprogram', substring($modelName,0,8)) {
	CREATE NCPROGRAM ${substring($modelName,0,8)}
}
 
$path = $path + "\" + substring($modelName,0,8)

if dir_exists($path) {
	message info "Project already exists"
	return
}

PROJECT SAVE AS FILESAVE $path

 

 

 

 

 

0 Likes
Message 5 of 5

moraschini
Enthusiast
Enthusiast

HELLO @g_borri 

TRY WITH THAT, I HOPE IT WORKS FOR YOUR NECESITIES

 

//EXTRACTING MODEL NAME (FIRST 8 CHARACTERS) AND SAVE THE FILE IF IT DOESN'T EXISTS
STRING $MODELNAME = FOLDER('model')[0].Name
STRING $SAVENAME = SUBSTRING($MODELNAME , 0 , 7)
STRING $SAVEDIRECTORY = "C:\Utenti\CAD22\Desktop\" + $SAVENAME 
IF NOT DIR_EXISTS($SAVEDIRECTORY) {
PROJECT SAVE AS $SAVEDIRECTORY
} ELSE {
PROJECT SAVE
}
//CREATE NCPROGRAM BASE ON MODEL NAME (FIRST 8 CHARACTERS) IF IT DOESN'T EXISTS
IF NOT ENTITY_EXISTS('NCPROGRAM' , $SAVENAME) {
CREATE NCPROGRAM ; EDIT NCPROGRAM ; QUIT FORM NCTOOLPATH
RENAME NCPROGRAM # $SAVENAME
NCTOOLPATH CANCEL FORM ACCEPT NCTOOLPATHLIST FORM ACCEPT NCTOOLLIST FORM ACCEPT PROBINGNCOPTS
}

 

0 Likes