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: 

macro help please! Check if all NCs are written...

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
rui.ramosQ3G7Y
212 Views, 2 Replies

macro help please! Check if all NCs are written...

Hello Guys,

I wounder if someone could help me out here, to see what am I doing wrong.

Im trying to build this macro to check if all NCs are written, if not, prompts a message in order for the user to see.

otherwise if all NCs are written it closes pmill.

 

macro:

DIALOGS ERROR OFF
DIALOGS MESSAGE OFF

 

FOREACH $nc IN FOLDER('ncprogram') {

IF $nc.Status == "not_written" {

message WARN "Some NCs are not written!!" + " " +CRLF+ " NC: " + $nc.name

} elseIF $nc.Status == "written" {

MESSAGE INFO "all NCs are written!!"

Exit

}
}
}

DIALOGS ERROR On
DIALOGS MESSAGE On

 

thanks in advance!

 

Good Day!

 

2 REPLIES 2
Message 2 of 3
TK.421
in reply to: rui.ramosQ3G7Y

here you go! i changed your code a little and marked it up so you can see my thinking.

// Turn off messages
DIALOGS ERROR OFF
DIALOGS MESSAGE OFF

// Initialize some variables
BOOL b = false
STRING s = ""

// Loop through NC Programs, checking for any that
// are unwritten. If there's an unwritten program, 
// make the BOOL true, get the name of the program
// and exit the loop
FOREACH $nc IN FOLDER('ncprogram') {
	IF $nc.Status == "not_written" {
		$b = true
		$s = $nc.Name
		BREAK
	}
}

// If the BOOL is true, pop the message warning the user,
// if it is false, save and close the project
IF $b == true {
	MESSAGE WARN "Some NCs are not written!!" + " " + CRLF + " NC: " + $s
	DIALOGS ERROR ON
	DIALOGS MESSAGE ON
} ELSE {
	DIALOGS ERROR ON
	DIALOGS MESSAGE ON
	PROJECT SAVE 
	EXIT
}
--------------------------------------
the numbers never lie
Message 3 of 3
rui.ramosQ3G7Y
in reply to: TK.421

Perfect!!
thank you very much!!

have a nice day!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report