In CATIA Generative Shape Design workbench, Law features can be used for precise control of the shape of a curve or a surface. While the use of the sketch-based laws has already been well described in a Rand 3D blog (see the post “How to control parameters in CATIA Generative Shape Design workbench using Advanced Law”, posted by Trisha Freeman 02/07/2018), sketch-based laws have limitations.

Consider this task: How do I create an offset curve that is driven by a mathematical equation, for example ?

To do that with a sketch-based law, we would have to sketch that shape in the Sketcher workbench first, but - there’s no tool in the Sketcher that lets you control a curve with an equation!

In this post, I’ll explain how to use mathematical equations to control curves and surfaces in CATIA. I’ll use the Parallel Curve tool as an example, but the described method could be just as well applied in any Shape Design feature that has the Law option enabled.

The model is shown below. The offset curve is to be driven by the equation

First, we need to create the law. To do that, click the (Law) icon in the Knowledge toolbar to display the Law Editor dialog box. The right-hand side allows you to create formal parameters to be used in the law (“formal” in the sense that these are not actual parameters in a CATIA model, rather, they serve as the “input” and the “output” parameters in the law definition), the left-hand side is the law edition box.

The input parameter in our law (the ** x** value in our mathematical equation) is the ratio parameter along the line’s length. It’s a dimensionless parameter, and it has value 0 at the start of the line and value 1 at the end of the line. Since it’s dimensionless, select type

**in the pull-down list and click**

*Real***button in the right-hand side of the dialog box. Rename the parameter as**

*New Parameter of type***.**

*x*The output parameter (the ** y** value in our equation) is the amount of the offset in the Parallel Curve definition, measured in length units. Therefore, select type

**and click**

*Length***button to create the output parameter. Rename the parameter as**

*New Parameter of type***.**

*y*Now, scroll down the ** Dictionary** section until you find the

**chapter, then locate the square root function**

*Math***(the synopsis means that the function requires input value of type**

*sqrt(Real):Real***and produces output value of type**

*Real***too) and double-click it in the list to put it into the law edition box.**

*Real*Type in the rest of the law as following: ** y = -50mm + 100mm*sqrt(x)**. Note the use of units, which is to ensure that the output parameter

**has length units. Click**

*y***to close the Law Editor when done.**

*OK*Now activate the Generative Shape Design (GSD) workbench and click the (Parallel Curve) icon. Select the curve to be offset and the support plane, then click ** Law** button.

In the Law Definition box, select the ** Advanced** option, then select the law (e.g. Law.1) in the tree. The Law Definition box now displays the preview of the curve. Note that the horizontal axis shows the ratio parameter from 0 to 1, while the vertical axis shows the amount of offset, from -50mm to 50mm.

Close the Law Definition and the Parallel Curve boxes. The resulting offset curve is created in the model, as shown below.

Another interesting possibility is that CATIA Law lets you use conditional statements ** if…else if…else**, which enables generation of “composite” curves, in which different sections in the curve are driven by different equations. For example, the law synopsis for a curve consisting of three sections would look as following:

**if** <input parameter is within certain range>

**{**

<1^{st} equation is used>

**}**

**else if** <input parameter is within some other range>

**{**

<2^{nd} equation is used>

**}**

**else**

**{**

<3^{rd} equation is used>

**}**

** **

As an example, let’s create a composite curve that is driven by our square root equation for the ratio parameter up to 0.5, and then it becomes a constant offset curve for the ratio parameter between 0.5 and 1. In this case, the law code would look as shown in the figure below: (Note that the resulting curve must be continuous at the junction points between the sections! The offset value 20.711mm is the value of our square root equation at x=0.5)

And the resulting curve would look as following:

The use of laws in Generative Shape Design is covered in the Rand 3D CATIA Advanced Surface Class.

## Comments

You can follow this conversation by subscribing to the comment feed for this post.