-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Absolute Coordinates of Reference #236
Comments
I think you have a few options:
I think for the latter two cases, you want to operate on a cell's import math
import gdstk
lib = gdstk.Library()
# Create a cell with collection of shapes that is used repeatedly
triangle = gdstk.regular_polygon((0, 6), 2, 3, rotation=math.pi)
single_triangle_cell = lib.new_cell("TRIANGLE_SINGLE")
single_triangle_cell.add(triangle)
def add_array(input_cell, output_cell, degrees_sweep, total_triangles):
number_repetitions = total_triangles
num_extra_triangles_from_full_rotation_sweep = degrees_sweep//360
degrees_separation = degrees_sweep/(number_repetitions-1+num_extra_triangles_from_full_rotation_sweep)
assert number_repetitions>0
for i in range(number_repetitions):
rotated_ref = gdstk.Reference(input_cell, (0, 0), rotation=-math.radians(degrees_separation*i))
output_cell.add(rotated_ref)
return output_cell
triangle_array_4_over_90_deg = add_array(single_triangle_cell, lib.new_cell("4_TRIANGLE_ARRAY"), 90, 4)
triangle_array_3_over_90_deg = add_array(single_triangle_cell, lib.new_cell("3_TRIANGLE_ARRAY"), 90, 3)
triangle_array_8_over_360_deg = add_array(single_triangle_cell, lib.new_cell("8_TRIANGLE_ARRAY"), 360, 8)
# now check references
ref_ids1 = set(triangle_array_8_over_360_deg.references)
ref_ids2 = set(triangle_array_4_over_90_deg.references)
print(ref_ids1)
print(ref_ids2)
common_refs = ref_ids1.intersection(ref_ids2)
print(f'common references: {common_refs}')
assert not common_refs
for ref in triangle_array_4_over_90_deg.references:
print(f'reference BB: {ref.bounding_box()}')
for i, p in enumerate(ref.get_polygons()):
print(f'\t polygon #{i} points: {",".join([str(pts) for pts in p.points])}')
lib.write_gds("testissue.gds") for me the output is:
|
dtzikas
pushed a commit
to dtzikas/gdstk
that referenced
this issue
Apr 18, 2024
Signed-off-by: Lucas Heitzmann Gabrielli <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @heitzmann, I want to ask that, how can I get the absolute coordinates of a reference according to its placement in a defined layout. Can we directly access a reference down the hierarchy?
The text was updated successfully, but these errors were encountered: