The #switch directive provides another way of specifying conditional expressions but allows you to handle a succession of conditions as defined by a #case clause or a #range clause. # infdef ( ObjectHeight ) #declare ObjectHeight = 1 #end The #switch, #case, #range and #break Directives These statements can help to trap potential errors in a scene file or to set default values. The #else directive is optional but, if specified and the identifier passed to the #ifdef directive does not exist, then directives between the #else and the corresponding #end statement are evaluated. If the identifier passed to the #ifdef directive exists then the statements between the #ifdef statement and a corresponding #else or #end statement are evaluated. The #ifdef and #ifndef statements can be used to determine whether or not an identifier has been defined and to conditionally execute statements. The #ifdef and #ifndef, #else and #end constructs Leaving the comment in place helps anyone reading it later.
![rhinoceros 5 break object apart rhinoceros 5 break object apart](http://docs.mcneel.com/rhino/5/help/en-us/image/topic_illustrations/non-manifoldedges-002.png)
It can help to write the condition out as a comment before you build it into an expression. The '&' symbol is used to combine the two and to therefore test for the condition where Clothing is "Jeans" and jeans are not permitted.Īs you've probably realised, there are many ways of expressing the same thing with conditional expressions and the art is in writing it in a way that is clear enough that you will understand it when you read it through again later. The '!' (Not) symbol is used to check for the condition where jeans are not permitted. The term 'strcmp(Clothing,"Jeans")=0' therefore returns a 1 (this term is true). In this example, the strcmp function returns a zero because there is no difference between the two strings it has compared. #declare Clothing = "Jeans" #declare JeansPermitted = false // Check to see if Jeans are permitted #if ( strcmp ( Clothing, "Jeans" ) = 0 & ! JeansPermitted ) #debug "Sorry. Here's an example that might take a little thinking about: The built-in float identifiers on, off, yes, no, true, and false are designed for use as boolean constants and simply evaluate to 0 (off, no and false) or 1 (on, yes and true). You can also use POV-Ray functions within terms so long as they can be resolved to numeric values. Use brackets to control the sequence of evaluation. You can combine conditional terms to build more complex conditional expressions using '&' (And), '|' (Or) and '!' (Not).
![rhinoceros 5 break object apart rhinoceros 5 break object apart](https://developer.rhino3d.com/api/cpp/class_o_n___curve.png)
In this example, the expression 'CameraDistance>100' evaluates to 0 ('false') because the CameraDistance variable is less than 100. Here the 'greater than' comparitive operator '>' is used to see whether the value of the CameraDistance variable is greater than 100. Definition of some complex object that looks like a sphere at great distances.
![rhinoceros 5 break object apart rhinoceros 5 break object apart](https://www.sculpteo.com/media/imagecontent/rhinoimage015.jpg)
The #else directive is optional but, if specified and the conditional expression was false, then directives between the #else and the corresponding #end statement are evaluated. Note: extremely small values of about 1e-10 are considered zero (false) as a result of floating point number accuracy limits. If the condition is true then directives between the #if statement and a corresponding #else or #end statement are evaluated.
![rhinoceros 5 break object apart rhinoceros 5 break object apart](https://venturebeat.com/wp-content/uploads/2018/09/IMG_20180903_102707-1.jpg)
This floating point number is interpreted as a boolean value, that is to say that if the expression evaluates to '0', it is considered 'false' and if it evaluates to anything else it is considered 'true'. This evaluates an expression, which must evaluate to a floating point number (often an integer value). The simplest conditional directive is the #if directive.