[OpenSCAD] Function to return the Opposite value

Alex Gibson alex at alexgibson.net
Thu Oct 31 10:51:53 EDT 2019


	oppositeThing = 1-isThing;

So if isThing is 1, oppositeThing is 0, and if isThing is 0, oppositeThing
is 1.

I sometimes also use this as a dirty way of enabling or disable whole chunks
of code, by putting it within a scale fubction - IE

module thingwithtwoversions()
		Your module, primary version
		Your module, alternate version

This can be done more intelligently using logical if statements but this way
is quick to insert!

Alex Gibson

admg consulting

edumaker limited

. Project management
. Operations & Process improvement 
. 3D Printing

-----Original Message-----
From: Discuss [mailto:discuss-bounces at lists.openscad.org] On Behalf Of Bryan
Sent: 31 October 2019 07:18
To: discuss at lists.openscad.org
Subject: [OpenSCAD] Function to return the Opposite value

I want to define a value at the top of my program:

	isThing=1;  // isThing can be 0 or 1

But later on I need to be able to use the opposite value.  
	1 if isThing==0 or
	0 if isThing==1

Note that this needs to be a number, not a boolean because I will be
multiplying vectors by it.

I am happy with either defining a variable or using a function to get this
opposite value.

How can I do this?

OpenSCAD mailing list
Discuss at lists.openscad.org

More information about the Discuss mailing list