with open(settings_file, 'r') as f:
    data = json.load(f)

brick = Element.from_data(data['brick'])
halfbrick = Element.from_data(data['halfbrick'])
width, length, height = data['brick_dimensions']

# Create assembly
assembly = Assembly()

# ==============================================================================
# Your code goes here.
# HINT: Use the examples to see how to re-use the brick/halfbrick elements
# defined above, and get a transformed instance of each of them as you
# build up your brick wall.
# Your code comes here

# ==============================================================================

# Transform assembly to correct location and adjust if needed
assembly.transform(Translation([-0.26, -0.34, 0]))

# Save assembly to json
assembly.to_json(PATH_TO, pretty=True)

# Run this in rhino
if compas.IPY:
    from assembly.rhino import AssemblyArtist
    artist = AssemblyArtist(assembly, layer='COMPAS::Assembly')
    artist.clear_layer()
    artist.draw()
示例#2
0
    trajectory2 = robot.plan_motion(goal_constraints,
                                    start_configuration,
                                    planner_id='RRT',
                                    attached_collision_meshes=[brick_acm])

    # 3. Calculate a cartesian motion to the target_frame
    frames = [savelevel_target_frame, target_frame]

    start_configuration = trajectory2.points[
        -1]  # as start configuration take last trajectory's end configuration
    trajectory3 = robot.plan_cartesian_motion(
        robot.from_attached_tool_to_tool0(frames),
        start_configuration,
        max_step=0.01,
        attached_collision_meshes=[brick_acm])
    assert (trajectory3.fraction == 1.)

    # 4. Add the brick to the planning scene
    brick = CollisionMesh(element.mesh, 'brick_wall')
    scene.append_collision_mesh(brick)

    # 5. Add trajectories to element and set to 'planned'
    element.trajectory = [trajectory1, trajectory2, trajectory3]
    assembly.network.set_vertex_attribute(key, 'is_planned', True)
    # ==========================================================================

    time.sleep(1)

# 6. Save assembly to json
assembly.to_json(PATH_TO)