"""Select objects in current layer with the same line color and width. Bernhard Reiter 22.1.2001 just extends select_same_line_width_and_color.py Copyright 1999 Bernhard Herzog check documentation there. put it in ~/.sketch and add the line "import select_same_line_width_and_color" in your userhooks.py there. This library is free software; you can redistribute it and/or modify it under the terms of the GNU LGPL v2 Read the documentation for details. """ def select_same_line_color(context): doc = context.document select = [] properties = doc.CurrentProperties() if properties.HasLine(): color = properties.line_pattern.Color() width = properties.line_width layer = doc.ActiveLayer() doc.SelectNone() for obj in layer.GetObjects(): if obj.has_line: prop = obj.Properties() if prop.HasLine() and color == prop.line_pattern.Color() \ and width == prop.line_width: select.append(obj) doc.SelectObject(select, Sketch.const.SelectAdd) # register script import Sketch.Scripting Sketch.Scripting.AddFunction('select_same_line_width_and_color', 'Select Same Line Width&Color', select_same_line_color, script_type = Sketch.Scripting.AdvancedScript)