Python API Exercise
This section is a hands-on exercise track for the Python API. It assumes you can already read and write basic FrameX, and teaches you to drive the engine from a Python program.
Seven tasks build one program step by step. Each task adds a few lines to the file you wrote in the task before, so work through them in order and keep your file.
How the solutions work
The solution to a task is at the top of the next page, folded away behind a Show the full program and what it prints toggle. So you reach an answer only by turning the page and then opening it, and you can read on past a solution without seeing it.
Every solution is the complete program as it stands at that point, together with the output it really prints. If your file has drifted, you can pick the thread back up from any page.
Before you start
Create main.py in your FrameX-Workbench workspace and press Run program to
run it; what your program prints appears in the result panel. framex is
already installed there, so from framex import Client works as it stands.
The running example is the family model from
Family Tree, cut down to two rules. Only the four
hasParent facts are stated — every sibling and grandparent answer you will
see is derived.