Skip to content

Commit

Permalink
open kicad after export
Browse files Browse the repository at this point in the history
  • Loading branch information
badgeek committed Apr 1, 2018
1 parent ee86b68 commit c6bec62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions inkscape/export_layers.inx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<param name="dpi" type="int" min="0" max="2000" _gui-text="Export DPI (default: 600)">600</param>

<param name="openfactory" type="boolean" gui-text="Open PCBWay after export?">true</param>
<param name="openkicad" type="boolean" gui-text="Open Kicad after export?">false</param>

<effect needs-live-preview="false">
<object-type>all</object-type>
Expand Down
23 changes: 20 additions & 3 deletions inkscape/export_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(self):
self.OptionParser.add_option("--dpi", action="store", type="float", dest="dpi", default=600)
self.OptionParser.add_option("--threshold", action="store", type="float", dest="threshold", default=128.0)
self.OptionParser.add_option("--openfactory", action="store", type="inkbool", dest="openfactory", default="true")
self.OptionParser.add_option("--openkicad", action="store", type="inkbool", dest="openkicad", default="true")


self.doc_width = 0
Expand Down Expand Up @@ -228,6 +229,8 @@ def effect(self):
self.setDocumentSquare()
self.setInkscapeScaling()
self.processExportLayer()
if (self.options.openfactory):
webbrowser.open("https://www.pcbway.com/setinvite.aspx?inviteid=54747", new = 2)
# inkex.debug(self.exportDrill())

def processExportLayer(self):
Expand Down Expand Up @@ -276,8 +279,6 @@ def processExportLayer(self):

counter = counter + 1

if (self.options.openfactory):
webbrowser.open("https://www.pcbway.com/setinvite.aspx?inviteid=54747", new = 2)


kicad_edgecut_string = self.exportEdgeCut()
Expand All @@ -296,7 +297,9 @@ def processExportLayer(self):
the_file.write(kicad_drill_string)
the_file.write(pcb_footer)


if (self.options.openkicad):
self.openKicad(kicad_pcb_path)

def export_layers(self, dest, show):
"""
Export selected layers of SVG to the file `dest`.
Expand Down Expand Up @@ -341,6 +344,20 @@ def get_layers(self, src):

return layers

def openKicad(self, kicad_file_path):
platform_system = platform.system()

if (platform_system == 'Darwin'):
command = "open %s" % (kicad_file_path)
elif (platform_system == 'Linux'):

This comment has been minimized.

Copy link
@5shekel

5shekel Apr 1, 2018

Contributor

xda-open doesn't register on my linux distro, xdg-open does

This comment has been minimized.

Copy link
@5shekel

5shekel Apr 1, 2018

Contributor

but it opens as text
% xdg-mime query filetype compiled.kicad_pcb text/plain

This comment has been minimized.

Copy link
@badgeek

badgeek Apr 1, 2018

Author Owner

aha its a typo should be xdg-open

command = "xda-open %s" % (kicad_file_path)
else:
command = "start %s" % (kicad_file_path)

p = subprocess.Popen(command.encode("utf-8"), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()



def exportToKicad(self, png_path, output_path, layer_type, invert = "true"):
plugin_path = os.path.dirname(os.path.abspath(__file__))
Expand Down

0 comments on commit c6bec62

Please sign in to comment.