So in the end, the only thing that should be changed is the values,You gave the solution yourself.
not the lists themselves... clear as mud?
Any hints, and/or suggestions are greatly appreciated,
I don't know if your inner polygons can contain lines and polygons, or
only lines, so:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2008 Medardo Rodriguez (Merchise Group)
#
# This is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License (GPL) as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# :)
def MoveDelta(targe t, dx, dy):
for item in target:
if isinstance(item[0], list): # is item a polygon?
MoveDelta(item, dx, dy) # Recursive version
else:
assert len(item) == 2 # make sure that it is a point
item[0] += dx
item[1] += dy
if __name__ == '__main__':
sample = [[[1, 2], [3, 4]], [[[7, 8], [10, 20]], [5, 6]]]
print 'Original:', sample
MoveDelta(sampl e, 10, 100)
print 'Result:', sample
# Regards