Skip to content
Snippets Groups Projects
Commit a70bd816 authored by Jingyan Ling's avatar Jingyan Ling
Browse files

remove redundant file, update journal

parent 86ac6d58
No related merge requests found
...@@ -191,8 +191,29 @@ ...@@ -191,8 +191,29 @@
- Obstacles setting are incorrect - Obstacles setting are incorrect
### 07/09/2019 ### 07/09/2019
- Finish up path-finding approach (Approach B)
- Only draw the best path on `dxf` when solution is found for every route. - Only draw the best path on `dxf` when solution is found for every route.
- ![circuit_dxf](journal_media/dxf_circuit.png) - ![circuit_dxf](journal_media/dxf_circuit.png)
- Throw warning once a route cannot be found - Throw warning once a route cannot be found
- ![fail_solution](journal_media/path_fail.gif) - ![fail_solution](journal_media/path_fail.gif)
- Research on Approach A
- KiCAD 5 does not have built-in auto-router
- Have to use `FreeRouting`
- `FreeRouting` does not have python API
- Parent package of `FreeRouting`, `LayoutEditor` has multiple editions
- Part of `LayoutEditor` is open- source
- A large amount of of its website are broken, source and interface are unavailable
- Other auto-routers are not open-source
##### Approach A
- 1. Use `LayoutEditor` python API to use `FreeRouting`
- 2. Use `KiCAD 5` python API to sue `FreeRouting`
- 3. Use `KiCAD 4` python API to use builtin auto-routing
- TODO:
- If can run KiCAD 4 from python
- Check `FreeRouting` API, see if a acceptable file can be generated from things on hand
...@@ -245,11 +245,11 @@ class auto_rounter: ...@@ -245,11 +245,11 @@ class auto_rounter:
print 'Current cost:',self.Q,'Best cost',self.Q_buff print 'Current cost:',self.Q,'Best cost',self.Q_buff
episode+=1 episode+=1
# if not self.final_fail: if not self.final_fail:
for i in range(len(self.final_path)): for i in range(len(self.final_path)):
self.draw_a_path(self.final_path[i],self.matrix,True) self.draw_a_path(self.final_path[i],self.matrix,True)
# else: else:
# print 'One or more path cannot be solved' print 'One or more path cannot be solved'
def test_connections(self): def test_connections(self):
y=97 y=97
......
This diff is collapsed.
import ezdxf
import random # needed for random placing points
import numpy as np
def get_random_point():
"""Creates random x, y coordinates."""
x = random.randint(-100, 100)
y = random.randint(-100, 100)
return x, y
# Create a new drawing in the DXF format of AutoCAD 2010
dwg = ezdxf.new('ac1024')
if not 'Isolation' in dwg.layers:
dwg.layers.new(name='Isolation',dxfattribs={'color':4})
# Create a block with the name 'FLAG'
flag = dwg.blocks.new(name='FLAG')
# Add DXF entities to the block 'FLAG'.
# The default base point (= insertion point) of the block is (0, 0).
# flag.add_polyline2d([(0, 0), (0, 5)]) # the flag as 2D polyline
flag.add_circle((0, 0), 5, dxfattribs={'color': 5}) # mark the base point with a circle
# flag.add_text("TEST").set_pos((25,280),align="MIDDLE_RIGHT")
# Get the modelspace of the drawing.
modelspace = dwg.modelspace()
modelspace.add_line((0.3,0.6),(40.5,0.6))
# Get 50 random placing points.
placing_points = [get_random_point() for _ in range(50)]
random_scale = 0.5 + random.random() * 2.0
# Add a block reference to the block named 'FLAG' at the coordinates 'point'.
modelspace.add_blockref('FLAG', (15,290), dxfattribs={
'layer':'Isolation',
})
modelspace.add_blockref('FLAG',(8,290))
modelspace.add_text("TEST").set_pos((10,285),align="MIDDLE_RIGHT")
for e in modelspace.query('LINE'):
print(e.dxf.start)
index_i=[]
index_j=[]
for line in modelspace.query('LINE'):
start=np.rint(line.dxf.start)
end=np.rint(line.dxf.end)
i=start[0]
j=start[1]
# index_i.append(i)
# index_j.append(j)
#can draw horizontal or vertical lines only
if j==end[1]: #this line is a horizontal line
index_i.append(i)
while i!=end[0]:
if i<end[0]:
i+=1
else:
i-=1
index_i.append(i)
elif i==end[0]: #this line is a vertical line
index_j.append(j)
while j!=end[1]:
if j<end[1]:
j+=1
else:
j-=1
index_j.append(j)
# Save the drawing.
dwg.saveas("testline.dxf")
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment