コード例 #1
0
def RunCommand(is_interactive):
    try:
        if 'compas_assembly' not in sc.sticky:
            raise Exception('Initialise the Assembly plugin first!')

        assembly = sc.sticky['compas_assembly']['assembly']
        settings = sc.sticky['compas_assembly']['settings']

        keys = AssemblyHelper.select_edges(assembly)
        if not keys:
            return

        if AssemblyHelper.update_edge_attributes(assembly, keys):
            assembly.draw(settings)

    except Exception as error:
        print(error)
        print(traceback.format_exc())
コード例 #2
0
    def assembly_move_vertex(self):
        key = AssemblyHelper.select_vertex(self.assembly)
        if key is None:
            return

        block = self.assembly.blocks[key]

        xyz_before = self.assembly.get_vertex_attributes(key, 'xyz')
        AssemblyHelper.move_vertex(self.assembly, key)
        xyz_after = self.assembly.get_vertex_attributes(key, 'xyz')

        translation = subtract_vectors(xyz_after, xyz_before)

        for key, attr in block.vertices(True):
            attr['x'] += translation[0]
            attr['y'] += translation[1]
            attr['z'] += translation[2]

        self.assembly.draw(self.settings['layer'])
コード例 #3
0
 def assembly_update_edge_attr(self):
     keys = AssemblyHelper.select_edges(self.assembly)
     if not keys:
         return
     if AssemblyHelper.update_edge_attributes(self.assembly, keys):
         self.assembly.draw(self.settings['layer'])
コード例 #4
0
 def assembly_select_vertices(self):
     AssemblyHelper.select_vertices(self.assembly)
コード例 #5
0
# draw blocks
# ==============================================================================

artist.draw_blocks()
artist.draw_vertices(color={
    key: '#ff0000'
    for key in assembly.vertices_where({'is_support': True})
})

artist.redraw()

# ==============================================================================
# identify support
# ==============================================================================

key = AssemblyHelper.select_vertex(
    assembly, "Select the vertex representing the support block.")

if key is not None:
    assembly.set_vertex_attribute(key, 'is_support', True)

# ==============================================================================
# draw blocks
# ==============================================================================

artist.clear_vertices()
artist.draw_vertices(color={
    key: '#ff0000'
    for key in assembly.vertices_where({'is_support': True})
})

artist.redraw()