Skip to content

Commit

Permalink
added coordinate conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
swissembedded committed May 31, 2019
1 parent 58d4b27 commit 2b73fed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def init_project_data():
# soldering toolpath
"SolderToolpath": [ # array with soldering points, referencing nc drill tool and position in list, selected soldering profile, attributes if reference point
# sort this array with PanelRef1 first, following closest neigbourst on optimize soldering points, do not sort imported nc hits and nc tools
# { "NCId" : 0, "NCPositionX": 0, "NCPositionY": 0, "NCTool":0, "PanelRef1": True, "PanelRef2":False, "SolderingProfile":-1, "ToolPathSorting" }
# { "NCId" : 0, "NCPositionX": 0, "NCPositionY": 0, "NCDiameter":0, "NCTool":0, "PanelRef1": True, "PanelRef2":False, "SolderingProfile":-1, "ToolPathSorting" }
]
# excellon
"NCSolderSide": "Top", # let user choose on import of nc file
Expand Down
30 changes: 30 additions & 0 deletions app/excellon.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def convert_to_json(ncdata):
hit[h]=ncdata.hits[h]
tool = hit.tool.number
pos=hit.position
dia=hit.diameter
soldertoolpath.append(
{# use index as id
"NCId" : h,
"NCPositionX": pos.x,
"NCPositionY": pos.y,
"NCTool" : tool,
"NCDiameter": dia,
"PanelRef1": False,
"PanelRef2":False,
# no soldering
Expand Down Expand Up @@ -172,3 +174,31 @@ def optimize_soldertoolpath(soldertoolpath,ncdata)
sortingIndex+=1
return soldertoolpath

# Get nc tool area
def get_nc_tool_area(soldertoolpath)
xmin=0
xmax=0
ymin=0
ymax=0
for e, elem in enumerate(solderingtoolpath):
tp=solderingtoolpath[e]
xemin=tp['NCPositionX']-(tp['NCDiameter']/2.0)
xemax=tp['NCPositionX']+(tp['NCDiameter']/2.0)
yemin=tp['NCPositionY']-(tp['NCDiameter']/2.0)
yemax=tp['NCPositionY']+(tp['NCDiameter']/2.0)
if e==0 OR xemin<xmin:
xmin=xemin
if e==0 OR xemax>xmax:
xmax=xemax
if e==0 OR yemin<ymin:
ymin=yemin
if e==0 OR yemax<ymax:
ymax=yemax
return xmin, xmax, ymin, ymax

# Get nc tool area
def get_nc_tool_position(soldertoolpath,x,y,w,h)
xmin, xmax, ymin, ymax=get_nc_tool_area(soldertoolpath)
xt=(x/w*(xmax-xmin))+xmin
xt=(y/h*(ymax-ymin))+ymin
return xt,yt

0 comments on commit 2b73fed

Please sign in to comment.