Changing the dart with logic
Now for the interesting part. Often a dart needs to be adjusted depending on measurements in a more complicated way. If some measurement is too small a dart may not be included, or in other situations a dart may be added. We are going to take a look at 3 ways to remove this dart depending on a measurement. We are going to base this on the measurement "Dart Depth".
Our pattern designer tells us that in this pattern, if the dart depth is less than 2 cm, we should leave the dart out. This calculation will depend on the width and height value of the user. How to program the decision? We’re going to show you three different ways. They use different MacroGen features to get the same end result: if the dart depth is less than 2 cm, it doesn’t draw the dart.
Here are the three ways we’re going to do it:
Condition: "If the dart depth is less than 2 cm."
-
Use an If Point to change a measure. If the condition is true, set the dart depth to 0.
-
Use an If Point to change the type of a point. If the condition is true, change point D3 from a Coordinate Point to a Center Point, centered between D1 and D2.
-
Use a Code Point to change a property of an object. We will draw the dart as a separate object from the square. If the condition is true, hide the dart object.