Please enable JavaScript to view this site.

Knowledge Bridge Documentation

Help version: 3.3.8

Navigation: Self-guided Training > Unit 8: Inheritance

Overriding Rules from Mixins

Scroll Prev Top Next More

 

When you mix designs into one of your Designs, you aren’t forced to just accept all the rules as defined in the mixins. You can define a Rule in your Design with the same name as a rule in the Mixin, and the rule definition in your Design will take precedence over the rule in the mixin. This is called "Overriding" the rule in the mixin.

 

In other words, a Rule in your Design always overrides a Rule that has the same name in a Mixin.

 

How to override

 

Let’s say you want to make the width (x dimension) of a Leg in the Table always the same as the length (y dimension) of the Leg. In other words, you want to have a square leg.

 

In our current Table project to this point, we did that by passing in this.length to both the width and length of the Leg"s Child, thus relying on the user of our Leg Design to enforce the "squareness" of the leg.

 

OverridingRules1

 

A better way to override

Create a Size rule and a SquareLeg Design

 

NOTE: although this is not in an Exercise section, please treat it as one. You should complete the steps below before moving to later Units.

 

A better way is to add a Size rule to the Leg Design and then make the width and length rules simply reference Size.

 

1.Below, create a SquareLeg Design that mixes in Block.

2.Add a size Parameter (rule) that is in the Inputs Category

3.Make the Design of the Leg's Child Group be SquareLeg by going to Leg's Child context and changing 'Leg' in the Design slot to 'SquareLeg' (with the quotes).

 

 

OverridingRules3a           OverridingRules3b

 

Now we want to change the length rule of our SquareLeg Design – but kBridge won’t let us edit length. What is wrong?

 

Notice the Owner column in the Rules Grid. The length and width rules are owned by the BoxMixin Design. That is a BaseLibrary Design – we don’t have write permission for it, so we can’t edit its rules. Length and width (and others) are inherited from BoxMixin and so we can’t edit those rules that come from that Mixin.

 

Instead, you need to create length and width rules in our SquareLeg Design to override those in BoxMixin.

 

And that is what the Override button does.

ClickOnOverride

 

If you select the length Rule in the grid and click the Override icon, the Rule Editor fills in with the length rule details from the underlying BoxMixin’s length Design. Notice the string at the top of the Rule Editor, in the yellow box below. It is telling you exactly what will happen—you are making an override.

 

OverridingRules4

 

We can adjust the rule’s type, flags, formula, etc., now to whatever we want. When we click Apply, our SquareLeg Design will now be the Owner of our new length rule. We didn’t delete it from the BoxMixin Design (we aren’t allowed to) – we just overrode it with a rule of the same name in our Design.

 

Now we can edit it to behave however we want. We remove the Parameter flag, change the category, and change the formula and click Apply.

OverridingRules5

Do the same for the width Rule so that our new square leg will only have parameters size and height. Length and width are calculated from the Size rule.

 

Make size = thickness

Now we supply a formula to the size Parameter of our Legs after which we will have a table that always has square legs that have size as their defining Parameter on both length and width.

 

Below, in the Leg0 Model under LegPair0, and in the Design Context, we have used Get Reference to create the formula for size, tying it to the thickness value of MyTable. That value is dependent on the load Parameter Rule of MyTable and changes between 3 and 6 depending on the table's load.

 

OverridingRules6

 

What Happens When You Delete Length?

If we were to delete our length rule in our SquareLeg Design – what happens? It gets deleted from our SqareLeg Design but it still exists in the BoxMixin Design, so the BoxMixin rule now becomes the active length rule again.

 

You Can Create an Override By Simply Creating a New Rule with the Same Name

You may be wondering – what if I just added a new rule with the same name as a rule in a mixin? Why do I have to use the Override button?

 

The answer: you can just make a new Rule, you don’t have to use the Override button at all. But it is more clear and explicit what is happening when you use the override technique. Other than that they are functionally exactly the same.

 

Knowledge Bridge from Engingeering Intent is a full-featured engineering and sales automation environment