|
| 1 | +--- |
| 2 | +title: Re-use blueprints across sessions and SDKs |
| 3 | +order: 150 |
| 4 | +--- |
| 5 | + |
| 6 | +While the [blueprint APIs](configure-viewer-through-code) are currently only available through [🐍 Python](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/), blueprints can be saved to file and then re-logged as needed from any language our SDKs support. |
| 7 | + |
| 8 | +This enables you to re-use your saved blueprints both from any language we support as well as across different recordings that share a similar-enough structure, and makes it possible to share those blueprints with other users. |
| 9 | + |
| 10 | +For this you'll need to 1) create a blueprint file and B) _import_ that file when needed. |
| 11 | + |
| 12 | + |
| 13 | +## Creating a blueprint file |
| 14 | + |
| 15 | +Blueprint files (`.rbl`, by convention) can currently be created in two ways. |
| 16 | + |
| 17 | +One is to use the Rerun viewer to interactively build the blueprint you want (e.g. by moving panels around, changing view settings, etc), and then using `Menu > Save blueprint` (or the equivalent palette command) to save the blueprint as a file. |
| 18 | + |
| 19 | +The other is to use the [🐍 Python blueprint API](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/) to programmatically build the blueprint, and then use the [`Blueprint.save`](https://ref.rerun.io/docs/python/0.19.0/common/blueprint_apis/#rerun.blueprint.Blueprint.save) method to save it as a file: |
| 20 | + |
| 21 | +snippet: tutorials/visualization/save_blueprint |
| 22 | + |
| 23 | + |
| 24 | +## (Re)Using a blueprint file |
| 25 | + |
| 26 | +There are two ways to re-use a blueprint file. |
| 27 | + |
| 28 | +The interactive way is to import the blueprint file directly into the Rerun viewer, using either `Menu > Import…` (or the equivalent palette command) or simply by drag-and-dropping the blueprint file into your recording. |
| 29 | + |
| 30 | +The programmatic way works by calling `log_file_from_path`: |
| 31 | +* [🐍 Python `log_file_from_path`](https://ref.rerun.io/docs/python/stable/common/logging_functions/#rerun.log_file_from_path) |
| 32 | +* [🦀 Rust `log_file_from_path`](https://docs.rs/rerun/latest/rerun/struct.RecordingStream.html#method.log_file_from_path) |
| 33 | +* [🌊 C++ `log_file_from_path`](https://ref.rerun.io/docs/cpp/stable/classrerun_1_1RecordingStream.html#a20798d7ea74cce5c8174e5cacd0a2c47) |
| 34 | + |
| 35 | +This method allows you to log any file that contains data that Rerun understands (in this case, blueprint data) as part of your current recording: |
| 36 | + |
| 37 | +snippet: tutorials/visualization/load_blueprint |
| 38 | + |
| 39 | + |
| 40 | +## Limitation: dynamic blueprints |
| 41 | + |
| 42 | +Sometimes, you might need your blueprint to dynamically react to the data you receive at runtime (e.g. you want to create one view per anomaly detected, and there is no way of knowing how many anomalies you're going to detect until the program actually runs). |
| 43 | + |
| 44 | +The only way to deal with these situations today is to use the [🐍 Python](https://ref.rerun.io/docs/python/stable/common/blueprint_apis/) API. |
0 commit comments