Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Replace Text NC

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
fg
Participant
955 Views, 6 Replies

Replace Text NC

Good evening, I can't do a macro:
Basically, I have to replace the first 5 characters of the NC programs with new 5 first characters of the model.

 

EXAMPLE: looking at the image, I would like all NC programs to be replaced and AA000 to be written instead of AT111

I managed to make a draft macro that I attach to this post, but with my macro I can ONLY do the first NC program.

I, on the other hand, would like to do them all.

 

 

FOREACH $progr IN folder('ncprogram') {
STRING vecchiocompleto = $progr.name

FOREACH $model IN folder('Model') {
STRING nuovocodice = substring($model.name, 0, 5)


FOREACH $progr IN folder('ncprogram') {
STRING vecchiocodice = substring($progr.name, 5, 50)


FOREACH $model IN folder('Model') {
STRING $nuovocompleto = nuovocodice + $vecchiocodice
PRINT $nuovocompleto
RENAME NCPROGRAM $vecchioCompleto $nuovocompleto
}
RESET LOCALVARS

Labels (2)
6 REPLIES 6
Message 2 of 7
rafael.sansao
in reply to: fg

IF SIZE(FOLDER("MODEL")) > 0 {
	STRING $nuovocodice = substring($FOLDER("MODEL")[0].name, 0, 5)
	FOREACH $ncp IN folder('ncprogram') {
		STRING $nuovocompleto = $nuovocodice + substring($ncp.name, 5, LENGTH($ncp.name))
		RENAME NCPROGRAM $ncp $nuovocompleto
	}
}

Rafael Sansão

EESignature

Message 3 of 7
fg
Participant
in reply to: fg

The script works perfectly. But I should change one thing. Basically I should figure out how to get the whole model name and not just the first 5 characters.

For Exemple: 

 

STRING $nuovocodice = substring($FOLDER("MODEL")[0].name, 0, 5)

 

In this code the number 5 should be replaced by the number of characters in the model.

To do this I thought of creating a variable where I entered the complete number of characters, but I do not know how I can do it

Message 4 of 7
rafael.sansao
in reply to: fg

Replace:

STRING $nuovocodice = substring($FOLDER("MODEL")[0].name, 0, 5)

By:

STRING $nuovocodice = $FOLDER("MODEL")[0].name

 

Rafael Sansão

EESignature

Message 5 of 7
fg
Participant
in reply to: rafael.sansao

It is correct but when I go to replace the code how do I get all the characters in the new code replaced?

 

IF SIZE(FOLDER("MODEL")) > 0 {
STRING $nuovocodice = substring($FOLDER("MODEL")[0].name)
FOREACH $ncp IN folder('ncprogram') {
STRING $nuovocompleto = $nuovocodice + substring($ncp.name, 5, LENGTH($ncp.name))
RENAME NCPROGRAM $ncp $nuovocompleto
}
}

 

The problem is that the "5" in the fourth line I want it to become the number of characters of the new code.

Message 6 of 7
rafael.sansao
in reply to: fg

This?

IF SIZE(FOLDER("MODEL")) > 0 {
	STRING $nuovocodice = $FOLDER("MODEL")[0].name
	FOREACH $ncp IN folder('ncprogram') {
		STRING $nuovocompleto = $nuovocodice + substring($ncp.name, LENGTH($nuovocodice), LENGTH($ncp.name))
		RENAME NCPROGRAM $ncp $nuovocompleto
	}
}

I'm not sure I understand what you want to do. Providing an example project of what it should look like after renaming would be nice.

Rafael Sansão

EESignature

Message 7 of 7
Hemant_2022
in reply to: rafael.sansao

Hello Everyone,

I am trying to make micro which change last character with user define word.

before run micro

Hemant_2022_0-1663832742460.jpeg

After run micro, !!!!! delete it and replace with user define word.

Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report