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

for switching

parent a90631c9
No related merge requests found
......@@ -12,7 +12,7 @@ class dxf_editor:
self.dwg=ezdxf.readfile(path+dxf_file)
self.msp=self.dwg.modelspace()
self.dxf_name='silhouette_ele.dxf'
self.img_name='silouette_ele.png'
# self.img_name='silouette_ele.png'
self.create_layer('Cut',5)
......@@ -28,6 +28,11 @@ class dxf_editor:
isolength=2.6 #mm
self.draw_on_pin(isolength)
self.matrix_shape=(210,270)
self.read_dxf_as_matrix()
self.dwg.saveas(self.dxf_name)
# os.system("inkscape -f silhouette_ele.dxf -e silouette_ele.png")
......@@ -76,7 +81,10 @@ class dxf_editor:
self.center_arr=np.unique(self.center_arr,axis=0)
self.center_arr=self.center_arr[1:]
# print(self.center_arr)
def remove_wheels(self):
#no need to call th
def draw_on_pin(self,fulllength): #isolation
iso=self.dwg.blocks.new(name='ISO_BLK')
isolength=fulllength/2
......@@ -91,36 +99,37 @@ class dxf_editor:
for center_point in self.center_arr:
self.msp.add_blockref('ISO_BLK',center_point,dxfattribs={'layer':'Circuit'})
# def img_color_convert(self):
# for i in range(self.img.shape[0]):
# for j in
def read_dxf_as_matrix(self):
"""unit: mm
accuracy issue expected atm (mm round up)
"""
self.matrix=np.zeros(self.matrix_shape)
for line in self.msp.query('LINE[layer!="Fold"]'):
start=np.rint(line.dxf.start)
end=np.rint(line.dxf.end)
self.matrix[int(start[0]),int(start[1])]=1
# print(self.matrix)
# if e.dxf.start[1]==e.dxf.end[1]: ##this line is horizontal
# midpoint_x=min(e.dxf.start[0],e.dxf.end[0])+length/2
# elif e.dxf.start[0]==e.dxf.end[0]: #This line is vertical
# midpoint_y=min(e.dxf.start[1],e.dxf.end[1])+length/2
# # print(midpoint)
# self.midpoint_arr=np.concatenate((self.midpoint_arr,np.array([midpoint])),axis=0)
# self.midpoint_arr=self.midpoint_arr[1:]
# self.midpoint_arr=np.unique(self.midpoint_arr,axis=0)
# print(self.midpoint_arr)
def main():
path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/'
dxf_file='graph-silhouette.dxf'
edit=dxf_editor(path,dxf_file)
# def main():
path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/'
dxf_file='graph-silhouette.dxf'
edit=dxf_editor(path,dxf_file)
if __name__ == '__main__':
main()
# if __name__ == '__main__':
# main()
# path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/'
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ $HANDLING
9
$TDUPDATE
40
2458667.67488
2458668.51773
9
$HANDSEED
5
......
silhouette_ele.png

40.9 KiB

......@@ -489,11 +489,11 @@ $SKPOLY
9
$TDCREATE
40
2458666.56804
2458668.49543
9
$TDUPDATE
40
2458666.56841
2458668.49543
9
$TDINDWG
40
......@@ -541,7 +541,7 @@ $SPLINESEGS
9
$HANDSEED
5
578
579
9
$SURFTAB1
70
......@@ -921,11 +921,11 @@ $PSTYLEMODE
9
$FINGERPRINTGUID
2
1D80ED02-9C40-11E9-8CCC-7470FDECECE4
D647F2AC-9DC3-11E9-8B04-7470FDECECE4
9
$VERSIONGUID
2
30220F18-9C40-11E9-8CCC-7470FDECECE4
D647F2AE-9DC3-11E9-8B04-7470FDECECE4
9
$EXTNAMES
290
......@@ -2795,7 +2795,7 @@ SECTION
2
ENTITIES
0
INSERT
LINE
5
575
330
......@@ -2807,6 +2807,28 @@ AcDbEntity
67
0
100
AcDbLine
10
0.3
20
0.6
11
40.5
21
40.2
0
INSERT
5
576
330
1F
100
AcDbEntity
8
Isolation
67
0
100
AcDbBlockReference
2
FLAG
......@@ -2825,7 +2847,7 @@ FLAG
0
INSERT
5
576
577
330
1F
100
......@@ -2853,7 +2875,7 @@ FLAG
0
TEXT
5
577
578
330
1F
100
......
......@@ -15,6 +15,7 @@ if not 'Isolation' in dwg.layers:
# 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
......@@ -23,6 +24,7 @@ flag.add_circle((0, 0), 5, dxfattribs={'color': 5}) # mark the base point with
# Get the modelspace of the drawing.
modelspace = dwg.modelspace()
modelspace.add_line((0.3,0.6),(40.5,40.2))
# Get 50 random placing points.
placing_points = [get_random_point() for _ in range(50)]
......@@ -36,7 +38,7 @@ modelspace.add_blockref('FLAG',(8,290))
modelspace.add_text("TEST").set_pos((10,285),align="MIDDLE_RIGHT")
for e in modelspace.query('*[layer=="Isolation"]'):
pass
for e in modelspace.query('LINE'):
print(e.dxf.start)
# Save the drawing.
dwg.saveas("testline.dxf")
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="793.700787402"
height="1122.51968504"
version="1.1"
id="svg43"
sodipodi:docname="testline.svg"
inkscape:version="0.92.4 (unknown)">
<metadata
id="metadata47">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview45"
showgrid="false"
inkscape:zoom="1.6819305"
inkscape:cx="68.223504"
inkscape:cy="1106.5586"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:current-layer="g33" />
<desc
id="desc2">/home/jingyan/Documents/summer_intern_lemur/roco_electrical/testline.dxf - scale = 1.000000, origin = (0.000000, 0.000000), method = manual</desc>
<defs
id="defs29">
<marker
id="DistanceX"
orient="auto"
refX="0.0"
refY="0.0"
style="overflow:visible">
<path
d="M 3,-3 L -3,3 M 0,-5 L 0,5"
style="stroke:#000000; stroke-width:0.5"
id="path4" />
</marker>
<pattern
height="8"
id="Hatch"
patternUnits="userSpaceOnUse"
width="8"
x="0"
y="0">
<path
d="M8 4 l-4,4"
linecap="square"
stroke="#000000"
stroke-width="0.25"
id="path7" />
<path
d="M6 2 l-4,4"
linecap="square"
stroke="#000000"
stroke-width="0.25"
id="path9" />
<path
d="M4 0 l-4,4"
linecap="square"
stroke="#000000"
stroke-width="0.25"
id="path11" />
</pattern>
<symbol
id="_ArchTick">
<path
d="M -1.889764,1124.409449 L 1.889764,1120.629921"
style="stroke:#000000;fill:none;stroke-linecap: round"
id="path14" />
</symbol>
<symbol
id="*Model_Space" />
<symbol
id="*Paper_Space" />
<symbol
id="FLAG">
<path
d="M 18.897638,1122.519685 A 18.897638,18.897638 -0.000000 1 0 -18.897638,1122.519685 18.897638,18.897638 -0.000000 1 0 18.897638,1122.519685 z"
style="stroke:#0000FF;fill:none"
id="path19" />
</symbol>
<symbol
id="_Open30">
<path
d="M -3.779528,1121.506964 0.000000,1122.519685"
style="stroke:#000000;fill:none;stroke-linecap: round"
id="path22" />
<path
d="M 0.000000,1122.519685 -3.779528,1123.532406"
style="stroke:#000000;fill:none;stroke-linecap: round"
id="path24" />
<path
d="M 0.000000,1122.519685 -3.779528,1122.519685"
style="stroke:#000000;fill:none;stroke-linecap: round"
id="path26" />
</symbol>
</defs>
<g
inkscape:groupmode="layer"
inkscape:label="0"
id="g33">
<use
transform="translate(26.074335,-1096.6576)"
xlink:href="#FLAG"
id="use31"
style="stroke:#800000"
x="0"
y="0"
width="100%"
height="100%" />
</g>
<g
inkscape:groupmode="layer"
inkscape:label="View Port"
id="g35" />
<g
inkscape:groupmode="layer"
inkscape:label="Defpoints"
id="g37" />
<g
inkscape:groupmode="layer"
inkscape:label="Isolation"
id="g41">
<use
transform="translate(52.531031,-1096.6576)"
xlink:href="#FLAG"
id="use39"
style="stroke:#800000"
x="0"
y="0"
width="100%"
height="100%" />
</g>
</svg>
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