diff --git a/doc/python.rst b/doc/python.rst index 5a97f377..ddaeb0a1 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -479,6 +479,7 @@ Below is a minimal usage example, more examples can be found in the Model Editin import mujoco spec = mujoco.MjSpec() + spec.modelname = "my model" body = spec.worldbody.add_body( pos=[1, 2, 3], quat=[0, 1, 0, 0], @@ -503,9 +504,30 @@ 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. -Attachments +Save to XML ----------- +Compiled ``MjSpec`` objects can be saved to XML string with the ``to_xml()`` method: + +.. code-block:: python + + print(spec.to_xml()) + +.. code-block:: XML + + + + + + + + + + + +Attachment +---------- + It is possible to combine multiple specs by using attachments. The following options are possible: - Attach a body from the child spec to a frame in the parent spec: ``body.attach_body(body, prefix, suffix)``, returns