It looks like you're new here. If you want to get involved, click one of these buttons!
I placed this in another discussion, but decided to move this to its own as it is unrelated to ruby, and it likely needs its own attention.
Is there a way to specify a different insertion point for instances of shapes or blocks in macros code for python?
For instance say I have a shape created in a cell and I want to create a few different versions of the position of this cell in new cells using the python macros for automating changes. I am looking to include a few other unchanging blocks, where their coordinates and positions align at the origin, but I want to place inside a new test feature with iterations of block conformations shifted by specific units--in particular it would be two of the same design shifted away from center by a unit of distance.
What I have for code looks something like this...
def _single_cell_create(self,
block_cell_name,
cell_contents):
# Create or find the block cell
block_cell = self.layout.create_cell(block_cell_name)
for _components in cell_contents:
block_layer_index, block_shape, block_coordinates = _components
# insert other normal/unchanging shapes to the block
block_cell.shapes(block_layer_index).insert(self.block_shape_add1)
block_cell.shapes(block_layer_index).insert(self.block_shape_add2)
block_cell.shapes(block_layer_index).insert(self.block_shape_add3)
block_cell.shapes(block_layer_index).insert(block_shape) # Not sure what to put here or where to specify insertion points
# specify some coordinates for this shape...
# Create the insertion point at specified block_coordinates away from center in both positive and negative directions
Inside the cell_contents, I envision that there would be a tuple of an integer (layer), string (block or shape), and some coordinates. However I cannot seem to see where to put the coordinates into the block_cell object for where they should go, or what reference origin point would be used generally.
Is there a way to do this that isn't by hand, as in creating the blocks ahead of time?
Comments
Hi @double0darbo,
I saw the other thread and replied. But it makes more sense as a separate one.
All the working shape objects (Polygon, Box, ... and corresponding D... types) have a method called "moved". You can create a displaced version with this method. The argument is an x,y pair or a Vector object. The result is a moved version of the original object.
Saying "reference point" implies that you want to place a certain point of a shape to some target location. That is just a matter of simple arithmetics. For example, to place the lower left corner of a Polygon's bounding box to some location, use:
If "polygon" is a DPolygon (in micrometer units), "target" needs to be a "DPoint" (also in micrometer units). If "polygon" is a Polygon (in DBU units), "target" needs to be a "Point" (also in DBU units).
Matthias