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

update journal

parent 630d7609
Branches
No related merge requests found
Showing
with 8319 additions and 25 deletions
......@@ -303,3 +303,35 @@
- 3. Put internal cut on different layer in KiCAD that can be read as obstacle in auto-router
- Best solution for now if the auto-router will be able to read single cut line, but cannot be edge.cut layer for sure, otherwise board outlines cannot be found by KiCAD.
- Cut lines causing issues are marked in red.
- ![](journal_media/internal_cut_marked.png)
- `Inkscape` :
- Object stroke to path can make everything looks like a bounding box
- Attempts:
- 1. Stroke every line, auto-router shows nothing, no error
- ![](journal_media/show_nothing_strokeeveryline.png)
- ![](journal_media/attempt1_3d.png)
- 2. Stroke every line, but has a larger boundary. auto-router shows nothing, error: cannot start a route inside of keepout area or boundary outlines
- ![](journal_media/show_nothing_strokewithalargerboundary.png)
- ![](journal_media/attempt2_3d.png)
- 3. Stroke every line but make the boundary outlines not closed, and draw a larger outline. Auto-router shows nothing, no error
- ![](journal_media/attempt3_2d.png)
- ![](journal_media/attempt3_3d.png)
- 4. Stroke only outline but make the boundary outlines not closed, and draw a larger outline. Auto-router shows properly. (no way to do it from script)
- ![](journal_media/attempt4_2d.png)
- ![](journal_media/attempt4_3d.png)
- ![](journal_media/attempt4_router.png)
### 07/16/2019
- Fill and Stroke (Shift + Ctrl + F)
- Stroke to Path
- Union
- Break Apart
- Remove each outer layer (manually)
- Export
- ![](journal_media/attempt5_2d.png)
- ![](journal_media/attempt5_3d.png)
- ![](journal_media/attempt5_router.png)
\ No newline at end of file
File moved
#!/usr/bin/env python
import numpy as np
import ezdxf
import random
from math import sqrt
import copy
class kicad_importer():
def __init__(self,path,dxf_file):
self.dwg=ezdxf.readfile(path+dxf_file)
self.msp=self.dwg.modelspace()
self.dxf_name='paperbot_kicad.dxf'
self.fail_flag=False #return True when path not found
self.create_layer('Cut',5)
self.create_layer('Circuit',1)
self.create_layer('Label',3)
self.create_layer('Fold',4)
self.create_layer('Pin_temp',6)
self.layer_rearrange() ## reagrrange cut and fold lines to corresponding layers
self.remove_wheels() ##remove wheel drawings for this design, no need to call for other designs
self.find_pin()
# horizonal=[113.468,151.468]
# self.seprate_blocks(horizonal)
self.dwg.saveas(self.dxf_name)
def create_layer(self,layer_name,color):
if not layer_name in self.dwg.layers:
self.dwg.layers.new(name=layer_name,dxfattribs={'color':color})
def layer_rearrange(self):
# put fold lines to the new layer 'Fold'
# put cut lines to the new layer 'Cut
for e in self.msp.query('LINE'):
if e.dxf.color!=5:
e.dxf.layer='Fold'
else:
e.dxf.layer='Cut'
def remove_wheels(self):
#no need to call this function for other design
for e in self.msp.query('Arc LINE[layer=="Cut"]'):
if e.dxf.start[0]>=179:
self.msp.delete_entity(e)
def find_pin(self):
tolerance=0.05 #mm
pincutsize=1 #mm
pin_edge_arr=np.array([[0,0],[0,0]]).reshape(1,2,2)
self.center_arr=np.array([[0,0]])
for e in self.msp.query('LINE[layer=="Cut"]'):
length= sqrt((e.dxf.start[0]-e.dxf.end[0])**2+(e.dxf.start[1]-e.dxf.end[1])**2)
if length > pincutsize-tolerance and length < pincutsize + tolerance:
e.dxf.layer='Pin_temp'
if e.dxf.start[1]==e.dxf.end[1]: ##this line is horizontal
pin_edge=np.array([e.dxf.start,e.dxf.end])[:,:2]
pin_edge_arr=np.concatenate((pin_edge_arr,pin_edge.reshape(1,2,2)),axis=0)
pin_edge_arr=pin_edge_arr[1:]
# print(pin_edge_arr)
for i in range(len(pin_edge_arr)):
for e in np.delete(pin_edge_arr,i,axis=0):
if pin_edge_arr[i][0,1]-e[0,1]==1.0:
center_x=pin_edge_arr[i][0,0]-0.5
center_y=pin_edge_arr[i][0,1]-0.5
center=np.array([center_x,center_y]).reshape(1,2)
self.center_arr=np.append(self.center_arr,center,axis=0)
self.center_arr=np.unique(self.center_arr,axis=0)
self.center_arr=self.center_arr[1:]
# print(self.center_arr)
# def seprate_blocks(self,horizontal,vertical=[]):
# """
# horizontal: an array with each element representing horizontal internal cut(from small to large value )
# vertical: an array with each element representing vertical internal cut (from small to large value)
# this function moves every line above the horizonal coordinate/ on the right of vertical coordinate to make outlines a closed shape"""
# cut_thickness=0.1
# if len(horizontal)!=0:
# for axis in horizontal:
# for e in self.msp.query('*'):
# if e.dxf.start[1]>axis or e.dxf.end[1]>axis:
# e.dxf.start[1]+=cut_thickness
# e.dxf.end[1]+=cut_thickness
path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/'
dxf_file='graph-silhouette.dxf'
importer=kicad_importer(path,dxf_file)
\ No newline at end of file
journal_media/attempt1_3d.png

17.6 KiB

journal_media/attempt2_3d.png

37.1 KiB

journal_media/attempt3_2d.png

16.2 KiB

journal_media/attempt3_3d.png

40.9 KiB

journal_media/attempt4_2d.png

14.6 KiB

journal_media/attempt4_3d.png

19.5 KiB

journal_media/attempt4_router.png

14.5 KiB

journal_media/attempt5_2d.png

7.76 KiB

journal_media/attempt5_3d.png

36.7 KiB

journal_media/attempt5_router.png

9.59 KiB

journal_media/internal_cut_marked.png

11.9 KiB

journal_media/show_nothing_strokeeveryline.png

11.9 KiB

journal_media/show_nothing_strokewithalargerboundary.png

11.7 KiB

This diff is collapsed.
# load the LayoutScript module
import LayoutScript
# use LayoutScript without prefix
from LayoutScript import *
#create a new layout object
l=project.newLayout();
#rename a layer
layers.num(6).name="new text"
c=l.drawing.currentCell
c.cellName="test-cell-python"
c.addBox(0,0,5000,7000,5)
c.addRoundedBox(10000,0,5000,7000,500,5)
c.addChamferedBox(20000,0,5000,7000,500,5)
c.addCircleBox(point(0,10000),point(5000,17000),5)
c.addEllipse(5,point(12500,15000),2500,3500)
c.addPolygonArc(point(22500,15000),2500,3500,0,340,5)
e=c.addText(5,point(25,25000),layers.num(6).name)
e.setWidth(1000)
l.drawing.saveFile("/home/jingyan/Documents/summer_intern_lemur/roco_electrical/testout.gds")
print("Python script completed")
\ No newline at end of file
This diff is collapsed.
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