Form data

To avoid having to process the session file over and over again to extract the information about the form diagram, we export the Form Diagram data to a separate JSON file (form.json) that can then be used as input instead. We also draw the form diagram as a simple mesh in Rhino.

import json
from compas.utilities import DataDecoder
from compas_rv2.datastructures import FormDiagram
from compas_rhino.artists import MeshArtist

FILE_I = 'bm-3.rv2'
FILE_O = 'form.json'

with open(FILE_I, 'r') as f:
    session = json.load(f, cls=DataDecoder)

form = FormDiagram.from_data(session['data']['form'])
form.to_json(FILE_O)

artist = MeshArtist(form, layer="RV2::Mesh")
artist.clear_layer()
artist.draw_faces(join_faces=True)
artist.redraw()

After exporting the data we can create the form diagram as follows.

from compas_rv2.datastructures import FormDiagram

form = FormDiagram.from_json('form.json')

Last updated