Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Rename NcPrograms

p.valente
Enthusiast

Rename NcPrograms

p.valente
Enthusiast
Enthusiast

Hi,

I have a macro to rename all NCPROGRAMS in tree.

 

 

Reset localvars


//Deseja alterar todos os nome dos NCPROGRAMS ?

 

string yesorno = "Clica SIM, para renomear os Ncprograms" + crlf + "Clica NAO, para cancelar a macro"
bool yes = 0
$yes = QUERY $yesorno

IF yes {


STRING $nombre = ""

INT $COUNT = INPUT "Introduz numero do primeiro programa"


// Nomear todos os Ncprograms ou só os selecionados

 

string allorno = "Click SIM, para renomear os Ncprograms" + crlf + "Clica NAO, outras opcoes"
bool yes = 0
$yes = QUERY $allorno

 

IF $yes == 1 {

 

// Numerar todos os Ncprograms

 

FOREACH Ncp IN folder ('NCProgram') {
ACTIVATE NCPROGRAM $Ncp.name
STRING NewName = ($nombre + $COUNT)
$COUNT = $COUNT + 1

RENAME NCPROGRAM ; $NewName
}

 


}

 

 

 

The problem is: this macro rename all programs inside NCPROGRAM tree.

Is it possible rename the programs only inside ACTIVE FORDER ? (Red Arrow)

 

 

red arrow.png

 

Thanks in advance 

With best regards

Pedro Valente

0 Likes
Reply
Accepted solutions (1)
546 Views
2 Replies
Replies (2)

Cobra.007
Enthusiast
Enthusiast
Accepted solution

Try the following

 

 

STRING NewName = ""

STRING Fold = ACTIVE_FOLDER()

 

FOREACH Ncp IN folder ($Fold) {
ACTIVATE NCPROGRAM $Ncp.name
$NewName = ($nombre + $COUNT)
$COUNT = $COUNT + 1

RENAME NCPROGRAM ; $NewName

p.valente
Enthusiast
Enthusiast

All Perfect..

Thank you Thank you