Offsets

The examples shown in this section were created using RV2 v1.0.0. They will be updated soon, and be compatible with the latest release of RV2.

from compas.geometry import add_vectors, scale_vector
from compas.datastructures import Mesh
from compas_rhino.artists import MeshArtist

FILE_I = 'form_dual.json'

FILE_O1 = 'form_idos.json'
FILE_O2 = 'form_edos.json'

mesh = Mesh.from_json(FILE_I)

idos = mesh.copy()
edos = mesh.copy()

for vertex in mesh.vertices():
    point = mesh.vertex_coordinates(vertex)
    normal = mesh.vertex_normal(vertex)
    thickness = 0.10
    idos.vertex_attributes(vertex, 'xyz', add_vectors(point, scale_vector(normal, +0.5 * thickness)))
    edos.vertex_attributes(vertex, 'xyz', add_vectors(point, scale_vector(normal, -0.5 * thickness)))

idos.to_json(FILE_O1)
edos.to_json(FILE_O2)

artist = MeshArtist(None)

artist.mesh = idos
artist.layer = "RV2::Idos"
artist.clear_layer()
artist.draw_faces(color=(255, 0, 0))

artist.mesh = edos
artist.layer = "RV2::Edos"
artist.clear_layer()
artist.draw_faces(color=(0, 0, 255))

artist.redraw()

Last updated