Modify Placement Rules

It will sometimes be necessary to change the placement rules or make new ones. For example, you might want to generate specific events and/or edge conditions. In this example, we will place a lamp near the credenza.

To accomplish this we will add a new rule. It is best to think about the placement rules a list of possible conditions that will execute if appropriate. Whether or not a rule is executed depends on various conditions, such as the size of the room and whether or not other rules are executed that a particular rule might be dependent on.

The rules start by defining a "parent" and "child"

        "parent": {"name": "credenza"},
        "child": {"category": "lamp"},

In this case, a credenza must be placed before the lamp. If we didn't want the lamp to have any dependency we could for example, "parent" the object to an architectural feature such as a wall.

Next, we will want to declare settings and rules. In this tutorial, we will not configure any settings for this relationship. We do cover the available options in the "placement.PlacementHandler" portion of the documentation.

        "rules": [
            ["neighbour", {"side": "left", "offset": [0.1, 0.3]}]
        ]

In this case, we only want one rule. We want to place the lamp to the "left" of the credenza between 0.1M and 0.3M away from the object.

Putting it all together your rule looks like this.

    {
        "parent": {"name": "credenza"},
        "child": {"category": "lamp"},
        "settings":{},
        "rules": [
            ["neighbour", {"side": "right", "offset": [0.1, 0.3]}]
        ]
    }

You will see in the following image that a lamp is now on the floor next to the credenza.

Last updated