Skip to content

Commit

Permalink
Fix coordinate issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettR committed Jul 18, 2018
1 parent ea9b530 commit b49388e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
11 changes: 7 additions & 4 deletions component_instances.py
Expand Up @@ -19,11 +19,14 @@ def upvComponentInstances(upv_component_instances, bounds):
used_count += 1
name = component_instance['attributes']['refdes']

translate_x = bounds['max_x'] - bounds['min_x']
translate_x += translate_x / 2
bounding_box_x = bounds['max_x'] - bounds['min_x']
translate_x = bounds['min_x']
translate_x += bounding_box_x / 2

bounding_box_y = bounds['max_y'] - bounds['min_y']
translate_y = bounds['min_y']
translate_y += bounding_box_y / 2

translate_y = bounds['max_y'] - bounds['min_y']
#translate_y += translate_y / 2
location = [nmToMm(component_instance['footprint_pos']['x'] - translate_x), nmToMm(component_instance['footprint_pos']['y'] - translate_y)]

silkscreen = {
Expand Down
16 changes: 11 additions & 5 deletions layout_objects.py
Expand Up @@ -35,12 +35,18 @@ def upvLayoutObjects(upv_layout_objects, bounds):
raise ValueError('Unexpected number of layout_object attributes! Please report an issue!')


translate_x = bounds['max_x'] - bounds['min_x']
translate_x += translate_x / 2
bounding_box_x = bounds['max_x'] - bounds['min_x']
translate_x = bounds['min_x']
translate_x += bounding_box_x / 2

translate_y = bounds['max_y'] - bounds['min_y']
#translate_y += translate_y / 2
location = [ nmToMm(layout_object['x'] - translate_x), nmToMm(layout_object['y'] - translate_y) ]
bounding_box_y = bounds['max_y'] - bounds['min_y']
translate_y = bounds['min_y']
translate_y += bounding_box_y / 2

x = nmToMm(layout_object['x'] - translate_x)
y = nmToMm(layout_object['y'] - translate_y)

location = [ x, y ]
footprint = createViaFootprint(layout_object['attributes'])

via = {
Expand Down
24 changes: 15 additions & 9 deletions trace_segments.py
Expand Up @@ -22,18 +22,24 @@ def upvTraceSegments(upv_trace_segments, bounds):
if len(trace_segment) != 6:
raise ValueError('Wrong number of trace_segment children! Please report an issue!')

translate_x = bounds['max_x'] - bounds['min_x']
translate_x += translate_x / 2
bounding_box_x = bounds['max_x'] - bounds['min_x']
translate_x = bounds['min_x']
translate_x += bounding_box_x / 2

translate_y = bounds['max_y'] - bounds['min_y']
#translate_y += translate_y / 2

bounding_box_y = bounds['max_y'] - bounds['min_y']
translate_y = bounds['min_y']
translate_y += bounding_box_y / 2

x1 = str(nmToMm(trace_segment['p1']['x'] - translate_x))
y1 = str(-1 * nmToMm(trace_segment['p1']['y'] - translate_y))
x2 = str(nmToMm(trace_segment['p2']['x'] - translate_x))
y2 = str(-1 * nmToMm(trace_segment['p2']['y'] - translate_y))

value = 'M ' + \
str(nmToMm(trace_segment['p1']['x'] - translate_x)) + ',' + \
str(-1 * nmToMm(trace_segment['p1']['y'] - translate_y)) + ' ' + \
str(nmToMm(trace_segment['p2']['x'] - translate_x)) + ',' + \
str(-1 * nmToMm(trace_segment['p2']['y'] - translate_y))
x1 + ',' + \
y1 + ' ' + \
x2 + ',' + \
y2
line = {
#In px
'stroke-width': nmToMm(trace_segment['width']),
Expand Down

0 comments on commit b49388e

Please sign in to comment.