py3dframe.Frame.from_json#
- classmethod Frame.from_json(filename)[source]#
Load the Frame object from a JSON file.
See also
method
from_dict()to load the Frame object from a dictionary.
- Parameters:
filename (str) – The name of the JSON file.
- Returns:
The Frame object.
- Return type:
Examples
Create a Frame object and save it to a JSON file using the default method (quaternion, rotation_vector, rotation_matrix):
from py3dframe import Frame frame = Frame.from_axes(origin=[1, 2, 3], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1], convention=0) frame.to_json("frame.json") # Reload the Frame object from the JSON file: loaded_frame = Frame.from_json("frame.json")
Warning, the method no longer saves the parent frame. To save/load a system of frames, consider using the
FrameTreeclass.from py3dframe import Frame parent = Frame.from_axes(origin=[0, 0, 0], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1], convention=0) child = Frame.from_axes(origin=[1, 0, 0], x_axis=[1, 0, 0], y_axis=[0, 1, 0], z_axis=[0, 0, 1], convention=0, parent=parent) child.to_json("child_frame.json") parent.to_json("parent_frame.json") # Reload the frames from the JSON files loaded_parent = Frame.from_json("parent_frame.json") loaded_child = Frame.from_json("child_frame.json") loaded_child.parent = loaded_parent # IMPORTANT