from compas.geometry import Box
from compas_rhino.artists import BoxArtist
from compas_rhino.artists import MeshArtist
from compas.datastructures import Mesh

# Box in the world coordinate system
frame = Frame([1, 0, 0], [-0.45, 0.1, 0.3], [1, 0, 0])
width, length, height = 1, 1, 1
box = Box(frame, width, length, height)

# Frame F representing a coordinate system
F = Frame([2, 2, 2], [0.978, 0.010, -0.210], [0.090, 0.882, 0.463])

# Get transformation between frames and apply transformation on box.
T = Transformation.from_frame_to_frame(Frame.worldXY(), F)
box_transformed = box.transformed(T)

# make Mesh from box
mesh_transformed = Mesh.from_shape(box_transformed)

# create Projection
P = Projection.from_plane_and_direction(Plane((0, 0, 0), (0, 0, 1)), (3, 5, 5))
P = Projection.from_plane(Plane((0, 0, 0), (0, 0, 1)))
P = Projection.from_plane_and_point(Plane((0, 0, 0), (0, 0, 1)), (3, 5, 5))

# apply transformation on mesh
mesh_projected = mesh_transformed.transformed(P)

# create artists
artist1 = BoxArtist(box_transformed)
artist2 = MeshArtist(mesh_projected)
Ejemplo n.º 2
0
    mpoints1.append(p1)
    mpoints2.append(p2)

for (a, b), (a1, b1), (a2, b2) in zip(pairwise(mpoints), pairwise(mpoints1), pairwise(mpoints2)):
    p = (a + b) * 0.5
    t = (b - a).unitized()
    n = Vector(0, 0, 1).cross(t)
    frame = Frame(p, t, n)
    frames.append(frame)
    l1 = (b1 - a1).length
    l2 = (b2 - a2).length
    block = Box(frame, min(l1, l2) - 0.03, 0.3, 0.1)
    block.transform(Translation.from_vector([0, 0, 0.1]))
    blocks1.append(block)

# ==============================================================================
# Visualization
# ==============================================================================

compas_rhino.clear_layers(["Wall::Blocks"])

for i in range(10):
    for block in blocks0:
        T = Translation.from_vector([0, 0, i * 0.2])
        artist = BoxArtist(block.transformed(T), layer="Wall::Blocks")
        artist.draw()
    for block in blocks1:
        T = Translation.from_vector([0, 0, i * 0.2])
        artist = BoxArtist(block.transformed(T), layer="Wall::Blocks")
        artist.draw()