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: 

Boolean function

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
PK_0
330 Views, 4 Replies

Boolean function

Hello. I need to write a function that returns a boolean value, which I can then use in an IF statement. I'm not entirely sure how to implement this correctly.
Could someone please provide an example of how this can be done? Any help or guidance would be greatly appreciated!

4 REPLIES 4
Message 2 of 5
TK.421
in reply to: PK_0

here's a quick example. what are you looking to return?
 
bool b = $toolpath.ZRange.Maximum.Active

// if the status is false pop message box
// (to check if true use '1')
IF b == 0 {
    MESSAGE INFO "No"
}
--------------------------------------
Former Expert Elite Member (not enough participation in all their webinars and other "stuff", even though I beta test and regularly contribute to the betterment of the software and the PowerMill community as a whole)

the numbers never lie
Message 3 of 5
icse
in reply to: PK_0

Can you tell us in detail what your goal is?

 

heres an example of a function that returns a boolean value:

function main() {
	
	bool $yourBool = 0
	
	call yourFunction($yourBool)

	if $yourBool {
		message info "True"
	} else {
		message info "False"
	}
}

function yourFunction(output bool $b) {
	$b = 1
}

when you call yourFunction in the main method the value gets changed to true.

Message 4 of 5
PK_0
in reply to: PK_0

What would be macro alternative to this python code?:

 

def is_even(number):
if number % 2 == 0:
return True
else:
return False


number_to_check = 4

if is_even(number_to_check):
print("even")
else:
print("odd")

Message 5 of 5
icse
in reply to: PK_0

i cant test it atm but it should look something like this:

 

function is_even(int $number, output bool $result) {
	if ($number % 2) == 0 {
		$result = True
	} else {
		$result = False
	}
}

function main() {
	int $number_to_check = 4
	
	bool $even = 0
	Call is_even($number_to_check,$even)
	
	if $even {
		message info "Even"
	} else {
		message info "Odd"
	}
}

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

Post to forums  

Autodesk Design & Make Report