Run the macro only if the selected item is correct

Run the macro only if the selected item is correct

HMC400
Advocate Advocate
809 Views
2 Replies
Message 1 of 3

Run the macro only if the selected item is correct

HMC400
Advocate
Advocate

Hi, as the title suggests, I wanted the macro to run only if the entity is correct.
I enclose what I tried to do, they look around on the Forum.
Specifically, I will insert the same block of text (which would be a stop) on all paths of a selected NC program.
If the selected entity is wrong, I wanted a message. If no entity is selected, I wanted another message.
Thank you all.

0 Likes
Accepted solutions (1)
810 Views
2 Replies
Replies (2)
Message 2 of 3

rafael.sansao
Advisor
Advisor
Accepted solution
INT $i = size(explorer_selected_entities())
IF $i > 0 {
	ENTITY ent = explorer_selected_entities()[0]
	IF $ent.RootType != "ncprogram" {
		MESSAGE INFO "Entity type selected: " + $ent.RootType
		MACRO ABORT
	}
	ACTIVATE NCPROGRAM $ent
	FORM TEXT
	EDIT TEXTBLOCK 'Text10' QUIT
	TEXT ACCEPT
	EDIT NCPROGRAM $StopProg INSERT TEXTBLOCKS
	STRING Expande=pathname(entity('ncprogram',''))
	EXPLORER SELECT NCPROGRAM $Expande NEW
	DEBUG EXPLORER KEY RIGHT
} ELSE {
	MESSAGE WARN "No ncprogram selected."
	MACRO ABORT
}

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 3 of 3

HMC400
Advocate
Advocate

Fantastic thank you so much

0 Likes