From f61973601ee9c7e7f1f6b8fbc5c7ba24b111195d Mon Sep 17 00:00:00 2001 From: Kevin Zakka Date: Tue, 28 Jan 2025 12:33:04 -0800 Subject: [PATCH] [docs] Mention asset lookup in MjSpec construction. PiperOrigin-RevId: 720671094 Change-Id: I6ba343b37893620ba4f3477e57daa4876805156c --- doc/python.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/python.rst b/doc/python.rst index e5c7ac0b..af435395 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -504,6 +504,20 @@ The ``MjSpec`` object wraps the :ref:`mjSpec` struct and can be constructed in t Note the ``from_string()`` and ``from_file()`` methods can only be called at construction time. +Assets +^^^^^^ + +All three methods allow one to specify a dictionary of assets that will be used +to resolve asset references in the XML. The dictionary maps from asset +name (string) to asset data (bytes), and can be assigned to the ``assets`` +attribute before calling ``compile()``, as demonstrated below. + +.. code-block:: python + + assets = {'image.png': b'image_data'} + spec = mujoco.MjSpec.from_string(xml_referencing_image_png, assets=assets) + model = spec.compile() + Save to XML -----------