Add displays to your Bot
This page explains how to add displays to the workflow so that they appear when the user opens the results of their workflow run.
1. The different displays
There are four displays that you can add to your workflow:
- Markdown: This can be used to present what the bot does or to present the results in text format.
- Multiplot: This is a graph that represents the relationship between the data of your object.
- Plot_data: This allows the representation of an object in 2D view.
- Cadview: This allows the representation of an object in 3D format.
2. How to add displays to your bot
- First, you have to implement a plot_data function (e.g. 2D plot) or volmdlr_primitives for CAD in your code.
- After coding your functions, you can add blocks to your workflow that allow you to read these functions.
- By clicking on the three dots of the workflow identification card, you can open a small modal page and then click on "Edit" to modify your workflow and add display blocks.
- By clicking on Edit, you will be redirected to the page where you can edit your workflow. In this example, we see our workflow with different blocks (methods, class) and we will add display blocks.
- To add a block, click on the "Add Block" button. This will open a drop-down menu where you can select the type of block to add.
In this example, we will present the installation of the four blocks of displays presented above. Before that, we will talk about the output results and the workflow. At the output, we have a list of "objects" represented by the block named "extract", as we can see with the red dot at the output of this block.
Markdown: We will add the markdown on the output of the block named "DATASET". This block contains all the solutions and is represented by the class named "DataSet". By clicking on "Add Block" and then "Markdown", a new window opens which allows you to fill in a few fields.
- Reset form: This allows you to go back by deleting the filled fields.
- Diff: By clicking on Diff, a window opens allowing you to see the modifications made in your form.
- Close: This closes the form.
- Save: This allows you to save the new block and have it in your workflow.
- Name: This represents the name of your block.
- Position: This represents the position of the blocks in the workflow.
By clicking on Save, the block will be added to your workflow and you just have to attach its input to the output of the previous block.
Multiplot: We will add the multiplot on the output of the block named "extract". This block contains all the solutions and is represented by a list. The multiplot block has as input a list of objects to make a graph that represents the relationship between the data of your objects.
- Attributes: This represents the attribute list of your object (an object from your list output) in this example, the attribute list of an object from the list output from the block named "extract". In other words, it represents the characteristics of the object (e.g. length, width, mass...).
- Order: This is an optional parameter that shows the order of the parameters that we will put in our scatter plot. If we put 0 in our scatter plot, we will have the first parameter and the second. If we put 1, we will have the second and the third, and so on.
Once all the fields are filled, we save and we link the input of the new block, in this case, it is a list of objects.
Plot_data: This block allows the representation of an object in 2D view. At the output of our workflow, we have a list of objects. For this, we will extract a solution from this list using the Unpacker block. Then we will add the block plot_data.
For this example, we take the first solution (the index 0 of our output list).
Name: This represents the name of your block.
The plot_data block does not require parameters in its input (like Markdown). It depends on what function you have programmed for your object.
Cadview: This block allows the representation of an object in 3D view. We will present the 3D view of the first object of the output list. The cadview block does not require parameters in its input (like Markdown or plot_data). It depends on what function you have programmed for your object.
This is what the new version of the workflow looks like after adding the display blocks. You just have to launch it to see the result after adding the display blocks.
3. Displays in the WorkflowRun page
After launching your new workflow, you open the result page. On this page, you will see the names of your new blocks appear in the part named DISPLAYS. The first two displays are by default. They represent the workflow documentation and the workflow, respectively. By checking the desired box, the display is shown. You can also display the display while checking the very first box.
Markdown:
Multiplot:
Note that the displayed solution for this workflow in plot_data and cadview is random. If you want to visualize another solution, you can select many solutions in multiplot and then click to display them.
Plot_data:
CAD view:
Go to the chapter Master 2D and 3D displays to learn more about display manipulation.