src/compas_3gs/rhino/objects/formnetworkobject.py
def draw(self):
        """Draw the objects representing the form diagram.
        """
        layer = self.settings['layer']
        self.artist.layer = layer
        self.artist.clear_layer()
        self.clear()
        if not self.visible:
            return
        self.artist.node_xyz = self.node_xyz

        # ======================================================================
        # Groups
        # ------
        # Create groups for nodes and edges.
        # These groups will be turned on/off based on the visibility settings of the diagram
        # ======================================================================

        group_nodes = "{}::nodes".format(layer)
        group_edges = "{}::edges".format(layer)
        group_angles = "{}::angles".format(layer)

        if not compas_rhino.rs.IsGroup(group_nodes):
            compas_rhino.rs.AddGroup(group_nodes)

        if not compas_rhino.rs.IsGroup(group_edges):
            compas_rhino.rs.AddGroup(group_edges)

        if not compas_rhino.rs.IsGroup(group_angles):
            compas_rhino.rs.AddGroup(group_angles)

        # ======================================================================
        # nodes
        # --------
        # Draw the nodes and add them to the node group.
        # ======================================================================

        nodes = list(self.network.nodes())
        color = {node: self.settings['color.nodes'] for node in nodes}
        color_fixed = self.settings['color.nodes:is_fixed']
        color.update({node: color_fixed for node in self.network.nodes_where({'is_fixed': True}) if node in nodes})

        guids = self.artist.draw_nodes(nodes, color)
        self.guid_node = zip(guids, nodes)
        compas_rhino.rs.AddObjectsToGroup(guids, group_nodes)

        if self.settings['show.nodes']:
            compas_rhino.rs.ShowGroup(group_nodes)
        else:
            compas_rhino.rs.HideGroup(group_nodes)

        # ======================================================================
        # Edges
        # --------
        # Draw the edges and add them to the edge group.
        # ======================================================================

        edges = list(self.network.edges())
        color = {edge: self.settings['color.edges'] for edge in edges}

        guids = self.artist.draw_edges(edges, color)
        self.guid_edge = zip(guids, edges)
        compas_rhino.rs.AddObjectsToGroup(guids, group_edges)

        if self.settings['show.edges']:
            compas_rhino.rs.ShowGroup(group_edges)
        else:
            compas_rhino.rs.HideGroup(group_edges)

        # ======================================================================
        # Angle deviations
        # --------
        # Draw angle deviatinos as FormNetwork edge labels.
        # ======================================================================

        if self.scene.settings['3GS']['show.angles']:
            tol = self.scene.settings['3GS']['tol.angles']
            edges = list(self.diagram.edges())
            angles = self.diagram.edges_attribute('_a', keys=edges)
            amin = min(angles)
            amax = max(angles)
            if (amax - amin)**2 > 0.001**2:
                text = {}
                color = {}
                for edge, angle in zip(edges, angles):
                    if angle > tol:
                        text[edge] = "{:.0f}".format(angle)
                        color[edge] = i_to_rgb((angle - amin) / (amax - amin))
                guids = self.artist.draw_edgelabels(text, color)
                self.guid_edgelabel = zip(guids, edges)
                compas_rhino.rs.AddObjectsToGroup(guids, group_angles)
                compas_rhino.rs.ShowGroup(group_angles)
        else:
            compas_rhino.rs.HideGroup(group_angles)

        self.redraw()
Draw the objects representing the form diagram.
        
Draw the objects representing the form diagram.
Draw the objects representing the form diagram .
def draw(self):
        layer = self.settings['layer']
        self.artist.layer = layer
        self.artist.clear_layer()
        self.clear()
        if not self.visible:
            return
        self.artist.node_xyz = self.node_xyz
        group_nodes = "{}::nodes".format(layer)
        group_edges = "{}::edges".format(layer)
        group_angles = "{}::angles".format(layer)
        if not compas_rhino.rs.IsGroup(group_nodes):
            compas_rhino.rs.AddGroup(group_nodes)
        if not compas_rhino.rs.IsGroup(group_edges):
            compas_rhino.rs.AddGroup(group_edges)
        if not compas_rhino.rs.IsGroup(group_angles):
            compas_rhino.rs.AddGroup(group_angles)
        --
        nodes = list(self.network.nodes())
        color = {node: self.settings['color.nodes'] for node in nodes}
        color_fixed = self.settings['color.nodes:is_fixed']
        color.update({node: color_fixed for node in self.network.nodes_where({'is_fixed': True}) if node in nodes})
        guids = self.artist.draw_nodes(nodes, color)
        self.guid_node = zip(guids, nodes)
        compas_rhino.rs.AddObjectsToGroup(guids, group_nodes)
        if self.settings['show.nodes']:
            compas_rhino.rs.ShowGroup(group_nodes)
        else:
            compas_rhino.rs.HideGroup(group_nodes)
        --
        edges = list(self.network.edges())
        color = {edge: self.settings['color.edges'] for edge in edges}
        guids = self.artist.draw_edges(edges, color)
        self.guid_edge = zip(guids, edges)
        compas_rhino.rs.AddObjectsToGroup(guids, group_edges)
        if self.settings['show.edges']:
            compas_rhino.rs.ShowGroup(group_edges)
        else:
            compas_rhino.rs.HideGroup(group_edges)
        --
        if self.scene.settings['3GS']['show.angles']:
            tol = self.scene.settings['3GS']['tol.angles']
            edges = list(self.diagram.edges())
            angles = self.diagram.edges_attribute('_a', keys=edges)
            amin = min(angles)
            amax = max(angles)
            if (amax - amin)**2 > 0.001**2:
                text = {}
                color = {}
                for edge, angle in zip(edges, angles):
                    if angle > tol:
                        text[edge] = "{:.0f}".format(angle)
                        color[edge] = i_to_rgb((angle - amin) / (amax - amin))
                guids = self.artist.draw_edgelabels(text, color)
                self.guid_edgelabel = zip(guids, edges)
                compas_rhino.rs.AddObjectsToGroup(guids, group_angles)
                compas_rhino.rs.ShowGroup(group_angles)
        else:
            compas_rhino.rs.HideGroup(group_angles)
        self.redraw()
def draw ( self ) : layer = self . settings [ 'layer' ] self . artist . layer = layer self . artist . clear_layer ( ) self . clear ( ) if not self . visible : return self . artist . node_xyz = self . node_xyz group_nodes = "{}::nodes" . format ( layer ) group_edges = "{}::edges" . format ( layer ) group_angles = "{}::angles" . format ( layer ) if not compas_rhino . rs . IsGroup ( group_nodes ) : compas_rhino . rs . AddGroup ( group_nodes ) if not compas_rhino . rs . IsGroup ( group_edges ) : compas_rhino . rs . AddGroup ( group_edges ) if not compas_rhino . rs . IsGroup ( group_angles ) : compas_rhino . rs . AddGroup ( group_angles ) nodes = list ( self . network . nodes ( ) ) color = { node : self . settings [ 'color.nodes' ] for node in nodes } color_fixed = self . settings [ 'color.nodes:is_fixed' ] color . update ( { node : color_fixed for node in self . network . nodes_where ( { 'is_fixed' : True } ) if node in nodes } ) guids = self . artist . draw_nodes ( nodes , color ) self . guid_node = zip ( guids , nodes ) compas_rhino . rs . AddObjectsToGroup ( guids , group_nodes ) if self . settings [ 'show.nodes' ] : compas_rhino . rs . ShowGroup ( group_nodes ) else : compas_rhino . rs . HideGroup ( group_nodes ) edges = list ( self . network . edges ( ) ) color = { edge : self . settings [ 'color.edges' ] for edge in edges } guids = self . artist . draw_edges ( edges , color ) self . guid_edge = zip ( guids , edges ) compas_rhino . rs . AddObjectsToGroup ( guids , group_edges ) if self . settings [ 'show.edges' ] : compas_rhino . rs . ShowGroup ( group_edges ) else : compas_rhino . rs . HideGroup ( group_edges ) if self . scene . settings [ '3GS' ] [ 'show.angles' ] : tol = self . scene . settings [ '3GS' ] [ 'tol.angles' ] edges = list ( self . diagram . edges ( ) ) angles = self . diagram . edges_attribute ( '_a' , keys = edges ) amin = min ( angles ) amax = max ( angles ) if ( amax - amin ) ** 2 > 0.001 ** 2 : text = { } color = { } for edge , angle in zip ( edges , angles ) : if angle > tol : text [ edge ] = "{:.0f}" . format ( angle ) color [ edge ] = i_to_rgb ( ( angle - amin ) / ( amax - amin ) ) guids = self . artist . draw_edgelabels ( text , color ) self . guid_edgelabel = zip ( guids , edges ) compas_rhino . rs . AddObjectsToGroup ( guids , group_angles ) compas_rhino . rs . ShowGroup ( group_angles ) else : compas_rhino . rs . HideGroup ( group_angles ) self . redraw ( )
Draw the objects representing the form diagram.
Draw the objects representing the form diagram .
"""Draw the objects representing the form diagram.
        """ # ====================================================================== # Groups # ------ # Create groups for nodes and edges. # These groups will be turned on/off based on the visibility settings of the diagram # ====================================================================== # ====================================================================== # nodes # -------- # Draw the nodes and add them to the node group. # ====================================================================== # ====================================================================== # Edges # -------- # Draw the edges and add them to the edge group. # ====================================================================== # ====================================================================== # Angle deviations # -------- # Draw angle deviatinos as FormNetwork edge labels. # ======================================================================
self