Help with IF Statement

Beta_Librae
Advocate
Advocate

Help with IF Statement

Beta_Librae
Advocate
Advocate

Salutations All,

 

Thought this one was gonna be easy for me, I was wrong.

 

Would greatly appreciate if anyone would tell me what's wrong with this code?

 

IF $Pattern == "CLAMP POCKET" {
RENAME Pattern "CLAMP POCKET" "CLAMP POCKET_1"


Kind Regards,
Not cnc, you can call me Peabrain
0 Likes
Reply
Accepted solutions (2)
486 Views
6 Replies
Replies (6)

gosmann.andreas
Advocate
Advocate
Accepted solution
STRING $CP = "CLAMP POCKET"
 IF ENTITY_EXISTS('pattern', CP) {
 RENAME Pattern $CP "CLAMP POCKET_1"
 }

Beta_Librae
Advocate
Advocate

Thank you kindly, much appreciated.

 

I'm guessing that I can follow the same format for a toolpath?


Kind Regards,
Not cnc, you can call me Peabrain
0 Likes

rafael.sansao
Advisor
Advisor
Accepted solution

You can also use the new_entity_name() command.

With this approach you will never get an error when running the macro.

 

STRING $CP = "CLAMP POCKET"
IF ENTITY_EXISTS("Pattern", $CP) {
	RENAME Pattern $CP ${new_entity_name("Pattern", $CP)}
}

 

STRING $TP = "TOOLPATH NAME"
IF ENTITY_EXISTS("Toolpath", $TP) {
	RENAME Toolpath $TP ${new_entity_name("Toolpath", $TP)}
}

 

Rafael Sansão

EESignature

Beta_Librae
Advocate
Advocate

Thanks Rafael,

 

Really appreciate your input. Always glad to know more ways than one.


Kind Regards,
Not cnc, you can call me Peabrain

dan_mickle
Participant
Participant
Does new_entity_name capture the name of the newly created entity automatically? How does it work?
0 Likes

rafael.sansao
Advisor
Advisor

rafaelsansao_0-1720470838488.png

 

Rafael Sansão

EESignature