def moveobjects(objects, x, y): moveObjects = [objects] if isinstance(objects, ListType): moveObjects = objects script = "" for object in moveObjects: script += "MOVE " + object + (" (%f %f);" % (x, y)) instance().executeCommand(COMMAND.executescr, [script])
def setGridUnitValue(value=-1): script = "GRID " if value == GRID.VALUE.FINEST: script += "FINEST;" elif value == GRID.VALUE.LAST: script += "LAST;" elif value == GRID.VALUE.DEFAULT or value == 0: script += "DEFAULT;" else: script += str(value) instance().executeCommand(COMMAND.executescr, [script])
def setGridUnitType(value): script = "GRID " if value == GRID.UNIT.MIC: script += "MIC;" elif value == GRID.UNIT.MM: script += "MM;" elif value == GRID.UNIT.MIL: script += "MIL;" elif value == GRID.UNIT.INCH: script += "INCH;" else: raise EaglepyException("Invalid unit type %s." % value) instance().executeCommand(COMMAND.executescr, [script])
def setgroup(objects): multi = False if isinstance(objects, ListType): multi = True objectsArg = objects if not multi else ";".join(objects) clrgroupall() result = instance().executeCommand(COMMAND.setgroup, [objectsArg])
def palette(index, type=PALETTE.DEFAULT): if index < 0 or index > PALETTE.ENTRIES - 1: raise EaglepyException("Invalid index %d. 0<index<%d" % (index, PALETTE.ENTRIES)) if type < PALETTE.DEFAULT or type > 2: raise EaglepyException("Invalie type index %d" % type) result = instance().executeCommand(COMMAND.palette, [index, type]) result = int(result) color = (result >> 16 & 255, result >> 8 & 255, result & 255, result >> 24 & 255) return color
def paletteall(type=PALETTE.DEFAULT): if type < PALETTE.DEFAULT or type > 2: raise EaglepyException("Invalie type index %d" % type) result = instance().executeCommand(COMMAND.paletteall, [type]) entries = [] for colorstr in result[1:].split(":"): color = int(colorstr) entries.append((color >> 16 & 255, color >> 8 & 255, color & 255, color >> 24 & 255)) return entries
def executescr(script): result = handleReplyError(instance().executeCommand(COMMAND.executescr, [script]))
def dlgMessageBox(message): return handleReplyError(instance().executeCommand(COMMAND.dlgMessageBox, [message]))
def getcontext(): return int(instance().executeCommand(COMMAND.getcontext))
def clrgroupall(): result = instance().executeCommand(COMMAND.clrgroupall)
def window(): instance().executeCommand(COMMAND.executescr, ["Window;"])
def status(message): instance().executeCommand(COMMAND.status, [message])
def executescr(script): instance().executeCommand(COMMAND.executescr, [script])
def selected(): return _objectsFromIndicies(handleReplyError(instance().executeCommand(COMMAND.getselected)))
def allobjects(): for index in range(len(__allobjects_cached_list)): __allobjects_cached_list.pop(0) for item in _objectsFromIndicies(handleReplyError(instance().executeCommand(COMMAND.allobjects))): __allobjects_cached_list.append(item) return __allobjects_cached_list