def METHOD_NAME(self, string):
    self.var.clear()
    self.comments = []
    self.reset()
    if string is None:
        return
    for line in string.split('\n'):
        if self.parse_variable(line):
            continue
        cmd, arglist, kwdict = self.syntax.parse_cmd(line)
        if cmd != 'draw':
            continue
        if len(arglist) == 0:
            raise InvalidSketchpadElementScript(
                f'Incomplete draw command: {line}')
        element_type = arglist[0]
        if not hasattr(self.element_module(), element_type):
            raise InvalidSketchpadElementScript(
                f'Unknown sketchpad element: {element_type}')
        element_class = getattr(self.element_module(), element_type)
        element = element_class(self, line)
        self.elements.append(element)
    self.elements.sort(
        key=lambda element:
        -element.z_index
        if isinstance(element.z_index, int)
        else 0
    )