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())
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'])
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'])
def assembly_select_vertices(self): AssemblyHelper.select_vertices(self.assembly)
# 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()