Help with IF Statement

Help with IF Statement

Beta_Librae
Advocate Advocate
696 Views
6 Replies
Message 1 of 7

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
Accepted solutions (2)
697 Views
6 Replies
Replies (6)
Message 2 of 7

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

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
Message 4 of 7

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

OptiNC - www.optinc.tech

EESignature

Message 5 of 7

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
Message 6 of 7

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

rafael.sansao
Advisor
Advisor

rafaelsansao_0-1720470838488.png

 

Rafael Sansão

OptiNC - www.optinc.tech

EESignature