adding command line flags and analyze
Signed-off-by: John Thornton <bjt128@gmail.com>
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
# dxf2gcode
|
# dxf2gcode
|
||||||
Don't confuse this with other dxf2gcode programs.
|
Don't confuse this with other dxf2gcode programs.
|
||||||
|
|
||||||
|
Status: Not Functioning
|
||||||
|
|
||||||
|
Current: adding command line flags and analyze
|
||||||
|
|
||||||
At this time dxf2gcode will convert a single layer DXF file to G code.
|
At this time dxf2gcode will convert a single layer DXF file to G code.
|
||||||
|
|
||||||
This is for G17 applications only at this time.
|
This is for G17 applications only at this time.
|
||||||
|
|
||||||
Set the output file directory to some directory you have.
|
|
||||||
|
|
||||||
Place the ini file in your home directory.
|
|
||||||
|
|||||||
171
dxf.glade
171
dxf.glade
@ -39,12 +39,7 @@
|
|||||||
<object class="GtkImage" id="image1">
|
<object class="GtkImage" id="image1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-convert</property>
|
<property name="stock">gtk-find</property>
|
||||||
</object>
|
|
||||||
<object class="GtkImage" id="image2">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-missing-image</property>
|
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkWindow" id="main_window">
|
<object class="GtkWindow" id="main_window">
|
||||||
<property name="width_request">600</property>
|
<property name="width_request">600</property>
|
||||||
@ -72,35 +67,33 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="file_open">
|
<object class="GtkMenuItem" id="file_open">
|
||||||
<property name="label">gtk-open</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">Open</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="activate" handler="on_file_open" swapped="no"/>
|
<signal name="activate" handler="on_file_open" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="file_convert">
|
<object class="GtkMenuItem" id="file_analyze">
|
||||||
<property name="label" translatable="yes">Convert</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="image">image1</property>
|
<property name="label" translatable="yes">Analyze</property>
|
||||||
<property name="use_stock">False</property>
|
<signal name="activate" handler="on_file_analyze" swapped="no"/>
|
||||||
<signal name="activate" handler="on_file_convert" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="imagemenuitem3">
|
<object class="GtkMenuItem" id="file_convert">
|
||||||
<property name="label">gtk-save</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="label" translatable="yes">Convert</property>
|
||||||
<property name="use_stock">True</property>
|
<signal name="activate" handler="on_file_convert" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -111,13 +104,22 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="file_quit">
|
<object class="GtkMenuItem" id="file_save">
|
||||||
<property name="label">gtk-quit</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">Save</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkMenuItem" id="file_quit">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">Quit</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="activate" handler="on_file_quit" swapped="no"/>
|
<signal name="activate" handler="on_file_quit" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
@ -137,43 +139,39 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="imagemenuitem6">
|
<object class="GtkMenuItem" id="imagemenuitem6">
|
||||||
<property name="label">gtk-cut</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">gtk-cut</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="imagemenuitem7">
|
<object class="GtkMenuItem" id="imagemenuitem7">
|
||||||
<property name="label">gtk-copy</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">gtk-copy</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="imagemenuitem8">
|
<object class="GtkMenuItem" id="imagemenuitem8">
|
||||||
<property name="label">gtk-paste</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">gtk-paste</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="imagemenuitem9">
|
<object class="GtkMenuItem" id="imagemenuitem9">
|
||||||
<property name="label">gtk-delete</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">gtk-delete</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -192,14 +190,11 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="view_test">
|
<object class="GtkMenuItem" id="view_test">
|
||||||
<property name="label" translatable="yes">Test</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
<property name="image">image2</property>
|
<property name="label" translatable="yes">Test</property>
|
||||||
<property name="use_stock">False</property>
|
|
||||||
<signal name="activate" handler="on_view_test" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -218,14 +213,12 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="help_about">
|
<object class="GtkMenuItem" id="help_about">
|
||||||
<property name="label">gtk-about</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="label" translatable="yes">gtk-about</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<signal name="activate" handler="on_help_about" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -288,17 +281,6 @@ Help > About</property>
|
|||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label7">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">label</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="tolerance_entry">
|
<object class="GtkEntry" id="tolerance_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -332,26 +314,6 @@ Help > About</property>
|
|||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="entry3">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="invisible_char">●</property>
|
|
||||||
<property name="primary_icon_activatable">False</property>
|
|
||||||
<property name="secondary_icon_activatable">False</property>
|
|
||||||
<property name="primary_icon_sensitive">True</property>
|
|
||||||
<property name="secondary_icon_sensitive">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHButtonBox" id="hbuttonbox1">
|
<object class="GtkHButtonBox" id="hbuttonbox1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -401,7 +363,7 @@ Help > About</property>
|
|||||||
<object class="GtkLabel" id="label13">
|
<object class="GtkLabel" id="label13">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">label</property>
|
<property name="label" translatable="yes">Default file name:</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">3</property>
|
||||||
@ -409,7 +371,7 @@ Help > About</property>
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="entry4">
|
<object class="GtkEntry" id="output_name_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="invisible_char">●</property>
|
<property name="invisible_char">●</property>
|
||||||
@ -425,6 +387,65 @@ Help > About</property>
|
|||||||
<property name="bottom_attach">4</property>
|
<property name="bottom_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="save_directory_entry">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="invisible_char">●</property>
|
||||||
|
<property name="invisible_char_set">True</property>
|
||||||
|
<property name="primary_icon_activatable">False</property>
|
||||||
|
<property name="secondary_icon_activatable">False</property>
|
||||||
|
<property name="primary_icon_sensitive">True</property>
|
||||||
|
<property name="secondary_icon_sensitive">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="find_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="image">image1</property>
|
||||||
|
<property name="image_position">right</property>
|
||||||
|
<signal name="clicked" handler="on_find_button" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label7">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Directory to save G code in:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
|
|||||||
31
dxf.py
31
dxf.py
@ -16,18 +16,23 @@ class Buglump:
|
|||||||
self.builder.add_from_file('dxf.glade')
|
self.builder.add_from_file('dxf.glade')
|
||||||
self.builder.connect_signals(self)
|
self.builder.connect_signals(self)
|
||||||
self.window = self.builder.get_object('main_window')
|
self.window = self.builder.get_object('main_window')
|
||||||
self.aboutdialog = self.builder.get_object("aboutdialog")
|
self.aboutdialog = self.builder.get_object('aboutdialog')
|
||||||
self.aboutdialog.set_version(version)
|
self.aboutdialog.set_version(version)
|
||||||
|
self.file_analyze = self.builder.get_object('file_analyze')
|
||||||
|
self.file_convert = self.builder.get_object('file_convert')
|
||||||
self.tolerance = self.builder.get_object('tolerance_entry')
|
self.tolerance = self.builder.get_object('tolerance_entry')
|
||||||
self.path = self.builder.get_object('path_entry')
|
self.path = self.builder.get_object('path_entry')
|
||||||
self.status = self.builder.get_object("status_label")
|
self.status = self.builder.get_object("status_label")
|
||||||
self.status.set_text('No File Open')
|
self.status.set_text('No File Open')
|
||||||
self.current_folder = os.path.expanduser('~')
|
self.current_folder = os.path.expanduser('~')
|
||||||
self.label2 = self.builder.get_object('label2')
|
self.label2 = self.builder.get_object('label2')
|
||||||
|
self.save_directory = self.builder.get_object('save_directory_entry')
|
||||||
|
self.output_name = self.builder.get_object('output_name_entry')
|
||||||
self.file_name = ''
|
self.file_name = ''
|
||||||
self.ini_file = ''
|
self.ini_file = ''
|
||||||
self.config = ConfigParser.ConfigParser()
|
self.config = ConfigParser.ConfigParser()
|
||||||
self.config.optionxform = str
|
self.config.optionxform = str
|
||||||
|
self.user_home = os.path.expanduser('~')
|
||||||
self.window.show()
|
self.window.show()
|
||||||
self.ini_check()
|
self.ini_check()
|
||||||
|
|
||||||
@ -48,10 +53,15 @@ class Buglump:
|
|||||||
self.status.set_text('File Selected %s' % self.fcd.get_filename())
|
self.status.set_text('File Selected %s' % self.fcd.get_filename())
|
||||||
self.file_name = "-f=" + self.fcd.get_filename()
|
self.file_name = "-f=" + self.fcd.get_filename()
|
||||||
self.current_folder = os.path.dirname(self.fcd.get_uri()[7:])
|
self.current_folder = os.path.dirname(self.fcd.get_uri()[7:])
|
||||||
|
self.file_analyze.set_sensitive(True)
|
||||||
|
self.file_convert.set_sensitive(True)
|
||||||
else:
|
else:
|
||||||
self.status.set_text('No File Open')
|
self.status.set_text('No File Open')
|
||||||
self.fcd.destroy()
|
self.fcd.destroy()
|
||||||
|
|
||||||
|
def on_file_analyze(self, menuitem, data=None):
|
||||||
|
print 'Analyze %s' % self.file_name
|
||||||
|
|
||||||
def on_file_convert(self, file_name, data=None):
|
def on_file_convert(self, file_name, data=None):
|
||||||
if len(self.file_name) > 0:
|
if len(self.file_name) > 0:
|
||||||
self.args = self.file_name
|
self.args = self.file_name
|
||||||
@ -95,10 +105,12 @@ class Buglump:
|
|||||||
self.build_ini()
|
self.build_ini()
|
||||||
|
|
||||||
def build_ini(self):
|
def build_ini(self):
|
||||||
cfgfile = open(self.ini_file,'w')
|
cfgfile = open(self.ini_file,'w+')
|
||||||
self.config.add_section('Configuration')
|
self.config.add_section('Configuration')
|
||||||
self.config.set('Configuration', 'TOLERANCE', '0.000001')
|
self.config.set('Configuration', 'TOLERANCE', '0.000001')
|
||||||
self.config.set('Configuration', 'PATH', 'CCW')
|
self.config.set('Configuration', 'PATH', 'CCW')
|
||||||
|
self.config.set('Configuration', 'SAVE_DIR', '')
|
||||||
|
self.config.set('Configuration', 'OUTPUT', 'output.ngc')
|
||||||
self.config.write(cfgfile)
|
self.config.write(cfgfile)
|
||||||
cfgfile.close
|
cfgfile.close
|
||||||
|
|
||||||
@ -110,16 +122,31 @@ class Buglump:
|
|||||||
try:
|
try:
|
||||||
self.tolerance.set_text(self.config.get('Configuration', 'TOLERANCE'))
|
self.tolerance.set_text(self.config.get('Configuration', 'TOLERANCE'))
|
||||||
self.path.set_text(self.config.get('Configuration', 'PATH'))
|
self.path.set_text(self.config.get('Configuration', 'PATH'))
|
||||||
|
self.save_directory.set_text(self.config.get('Configuration', 'SAVE_DIR'))
|
||||||
|
self.output_name.set_text(self.config.get('Configuration', 'OUTPUT'))
|
||||||
except:
|
except:
|
||||||
message = 'The preferences file is corrupt.\nRebuild with default settings?'
|
message = 'The preferences file is corrupt.\nRebuild with default settings?'
|
||||||
result = yesno_dialog(message)
|
result = yesno_dialog(message)
|
||||||
if result == gtk.RESPONSE_YES:
|
if result == gtk.RESPONSE_YES:
|
||||||
self.build_ini()
|
self.build_ini()
|
||||||
|
|
||||||
|
def on_find_button(self, data=None):
|
||||||
|
self.fcd = gtk.FileChooserDialog("Open...", None,
|
||||||
|
gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||||
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||||
|
self.fcd.set_current_folder(self.user_home)
|
||||||
|
self.response = self.fcd.run()
|
||||||
|
if self.response == gtk.RESPONSE_OK:
|
||||||
|
print "Selected filepath: %s" % self.fcd.get_filename()
|
||||||
|
self.save_directory.set_text(self.fcd.get_filename())
|
||||||
|
self.fcd.destroy()
|
||||||
|
|
||||||
def on_save_preferences(self, data=None):
|
def on_save_preferences(self, data=None):
|
||||||
cfgfile = open(self.ini_file, 'w')
|
cfgfile = open(self.ini_file, 'w')
|
||||||
self.config.set('Configuration', 'TOLERANCE', self.tolerance.get_text())
|
self.config.set('Configuration', 'TOLERANCE', self.tolerance.get_text())
|
||||||
self.config.set('Configuration', 'PATH', self.path.get_text())
|
self.config.set('Configuration', 'PATH', self.path.get_text())
|
||||||
|
self.config.set('Configuration', 'SAVE_DIR', self.save_directory.get_text())
|
||||||
|
self.config.set('Configuration', 'OUTPUT', self.output_name.get_text())
|
||||||
self.config.write(cfgfile)
|
self.config.write(cfgfile)
|
||||||
cfgfile.close()
|
cfgfile.close()
|
||||||
|
|
||||||
|
|||||||
216
dxf/test.dxf
216
dxf/test.dxf
@ -903,7 +903,7 @@ LAYER
|
|||||||
100
|
100
|
||||||
AcDbSymbolTable
|
AcDbSymbolTable
|
||||||
70
|
70
|
||||||
1
|
2
|
||||||
0
|
0
|
||||||
LAYER
|
LAYER
|
||||||
5
|
5
|
||||||
@ -925,6 +925,28 @@ CONTINUOUS
|
|||||||
370
|
370
|
||||||
0
|
0
|
||||||
390
|
390
|
||||||
|
F
|
||||||
|
0
|
||||||
|
LAYER
|
||||||
|
5
|
||||||
|
43
|
||||||
|
100
|
||||||
|
AcDbSymbolTableRecord
|
||||||
|
100
|
||||||
|
AcDbLayerTableRecord
|
||||||
|
2
|
||||||
|
Inside
|
||||||
|
70
|
||||||
|
0
|
||||||
|
62
|
||||||
|
7
|
||||||
|
6
|
||||||
|
CONTINUOUS
|
||||||
|
290
|
||||||
|
1
|
||||||
|
370
|
||||||
|
0
|
||||||
|
390
|
||||||
F
|
F
|
||||||
0
|
0
|
||||||
ENDTAB
|
ENDTAB
|
||||||
@ -1253,7 +1275,7 @@ ENTITIES
|
|||||||
0
|
0
|
||||||
ARC
|
ARC
|
||||||
5
|
5
|
||||||
43
|
44
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
8
|
8
|
||||||
@ -1283,7 +1305,7 @@ AcDbArc
|
|||||||
0
|
0
|
||||||
LINE
|
LINE
|
||||||
5
|
5
|
||||||
44
|
45
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
100
|
100
|
||||||
@ -1311,7 +1333,7 @@ ByLayer
|
|||||||
0
|
0
|
||||||
ARC
|
ARC
|
||||||
5
|
5
|
||||||
45
|
46
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
8
|
8
|
||||||
@ -1341,7 +1363,7 @@ AcDbArc
|
|||||||
0
|
0
|
||||||
LINE
|
LINE
|
||||||
5
|
5
|
||||||
46
|
47
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
100
|
100
|
||||||
@ -1369,7 +1391,7 @@ ByLayer
|
|||||||
0
|
0
|
||||||
ARC
|
ARC
|
||||||
5
|
5
|
||||||
47
|
48
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
8
|
8
|
||||||
@ -1399,34 +1421,6 @@ AcDbArc
|
|||||||
0
|
0
|
||||||
LINE
|
LINE
|
||||||
5
|
5
|
||||||
48
|
|
||||||
100
|
|
||||||
AcDbEntity
|
|
||||||
100
|
|
||||||
AcDbLine
|
|
||||||
8
|
|
||||||
0
|
|
||||||
62
|
|
||||||
256
|
|
||||||
370
|
|
||||||
-1
|
|
||||||
6
|
|
||||||
ByLayer
|
|
||||||
10
|
|
||||||
1.0
|
|
||||||
20
|
|
||||||
0.0
|
|
||||||
30
|
|
||||||
0.0
|
|
||||||
11
|
|
||||||
9.0
|
|
||||||
21
|
|
||||||
0.0
|
|
||||||
31
|
|
||||||
0.0
|
|
||||||
0
|
|
||||||
LINE
|
|
||||||
5
|
|
||||||
49
|
49
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
@ -1437,6 +1431,34 @@ AcDbLine
|
|||||||
62
|
62
|
||||||
256
|
256
|
||||||
370
|
370
|
||||||
|
-1
|
||||||
|
6
|
||||||
|
ByLayer
|
||||||
|
10
|
||||||
|
1.0
|
||||||
|
20
|
||||||
|
0.0
|
||||||
|
30
|
||||||
|
0.0
|
||||||
|
11
|
||||||
|
9.0
|
||||||
|
21
|
||||||
|
0.0
|
||||||
|
31
|
||||||
|
0.0
|
||||||
|
0
|
||||||
|
LINE
|
||||||
|
5
|
||||||
|
4A
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbLine
|
||||||
|
8
|
||||||
|
0
|
||||||
|
62
|
||||||
|
256
|
||||||
|
370
|
||||||
-1
|
-1
|
||||||
6
|
6
|
||||||
ByLayer
|
ByLayer
|
||||||
@ -1455,7 +1477,7 @@ ByLayer
|
|||||||
0
|
0
|
||||||
ARC
|
ARC
|
||||||
5
|
5
|
||||||
4A
|
4B
|
||||||
100
|
100
|
||||||
AcDbEntity
|
AcDbEntity
|
||||||
8
|
8
|
||||||
@ -1483,6 +1505,118 @@ AcDbArc
|
|||||||
51
|
51
|
||||||
270.0
|
270.0
|
||||||
0
|
0
|
||||||
|
LINE
|
||||||
|
5
|
||||||
|
4C
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbLine
|
||||||
|
8
|
||||||
|
Inside
|
||||||
|
62
|
||||||
|
256
|
||||||
|
370
|
||||||
|
-1
|
||||||
|
6
|
||||||
|
ByLayer
|
||||||
|
10
|
||||||
|
1.0
|
||||||
|
20
|
||||||
|
1.0
|
||||||
|
30
|
||||||
|
0.0
|
||||||
|
11
|
||||||
|
9.0
|
||||||
|
21
|
||||||
|
1.0
|
||||||
|
31
|
||||||
|
0.0
|
||||||
|
0
|
||||||
|
LINE
|
||||||
|
5
|
||||||
|
4D
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbLine
|
||||||
|
8
|
||||||
|
Inside
|
||||||
|
62
|
||||||
|
256
|
||||||
|
370
|
||||||
|
-1
|
||||||
|
6
|
||||||
|
ByLayer
|
||||||
|
10
|
||||||
|
9.0
|
||||||
|
20
|
||||||
|
1.0
|
||||||
|
30
|
||||||
|
0.0
|
||||||
|
11
|
||||||
|
9.0
|
||||||
|
21
|
||||||
|
9.0
|
||||||
|
31
|
||||||
|
0.0
|
||||||
|
0
|
||||||
|
LINE
|
||||||
|
5
|
||||||
|
4E
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbLine
|
||||||
|
8
|
||||||
|
Inside
|
||||||
|
62
|
||||||
|
256
|
||||||
|
370
|
||||||
|
-1
|
||||||
|
6
|
||||||
|
ByLayer
|
||||||
|
10
|
||||||
|
9.0
|
||||||
|
20
|
||||||
|
9.0
|
||||||
|
30
|
||||||
|
0.0
|
||||||
|
11
|
||||||
|
1.0
|
||||||
|
21
|
||||||
|
9.0
|
||||||
|
31
|
||||||
|
0.0
|
||||||
|
0
|
||||||
|
LINE
|
||||||
|
5
|
||||||
|
4F
|
||||||
|
100
|
||||||
|
AcDbEntity
|
||||||
|
100
|
||||||
|
AcDbLine
|
||||||
|
8
|
||||||
|
Inside
|
||||||
|
62
|
||||||
|
256
|
||||||
|
370
|
||||||
|
-1
|
||||||
|
6
|
||||||
|
ByLayer
|
||||||
|
10
|
||||||
|
1.0
|
||||||
|
20
|
||||||
|
9.0
|
||||||
|
30
|
||||||
|
0.0
|
||||||
|
11
|
||||||
|
1.0
|
||||||
|
21
|
||||||
|
1.0
|
||||||
|
31
|
||||||
|
0.0
|
||||||
|
0
|
||||||
ENDSEC
|
ENDSEC
|
||||||
0
|
0
|
||||||
SECTION
|
SECTION
|
||||||
@ -1521,7 +1655,7 @@ E
|
|||||||
3
|
3
|
||||||
AcDbVariableDictionary
|
AcDbVariableDictionary
|
||||||
350
|
350
|
||||||
4B
|
50
|
||||||
0
|
0
|
||||||
DICTIONARY
|
DICTIONARY
|
||||||
5
|
5
|
||||||
@ -1985,7 +2119,7 @@ Layout2
|
|||||||
0
|
0
|
||||||
DICTIONARY
|
DICTIONARY
|
||||||
5
|
5
|
||||||
4B
|
50
|
||||||
100
|
100
|
||||||
AcDbDictionary
|
AcDbDictionary
|
||||||
281
|
281
|
||||||
@ -1993,15 +2127,15 @@ AcDbDictionary
|
|||||||
3
|
3
|
||||||
DIMASSOC
|
DIMASSOC
|
||||||
350
|
350
|
||||||
4D
|
52
|
||||||
3
|
3
|
||||||
HIDETEXT
|
HIDETEXT
|
||||||
350
|
350
|
||||||
4C
|
51
|
||||||
0
|
0
|
||||||
DICTIONARYVAR
|
DICTIONARYVAR
|
||||||
5
|
5
|
||||||
4C
|
51
|
||||||
100
|
100
|
||||||
DictionaryVariables
|
DictionaryVariables
|
||||||
280
|
280
|
||||||
@ -2011,7 +2145,7 @@ DictionaryVariables
|
|||||||
0
|
0
|
||||||
DICTIONARYVAR
|
DICTIONARYVAR
|
||||||
5
|
5
|
||||||
4D
|
52
|
||||||
100
|
100
|
||||||
DictionaryVariables
|
DictionaryVariables
|
||||||
280
|
280
|
||||||
|
|||||||
2024
dxf/test.dxf~
Executable file
2024
dxf/test.dxf~
Executable file
File diff suppressed because it is too large
Load Diff
44
dxf2gcode.go
44
dxf2gcode.go
@ -12,33 +12,55 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var ( // flag variables
|
var ( // flag variables
|
||||||
file *string
|
input *string
|
||||||
direction *string
|
direction *string
|
||||||
|
output *string
|
||||||
|
analyze *bool
|
||||||
|
convert *bool
|
||||||
//port *int
|
//port *int
|
||||||
//yesno *bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Basic flag declarations are available for string, integer, and boolean options.
|
// Basic flag declarations are available for string, integer, and boolean options.
|
||||||
func init() { // flag.Type(flag, default, help string)
|
func init() { // flag.Type(flag, default, help string)
|
||||||
file = flag.String("f", "test.dxf", "Path to a DXF to convert")
|
input = flag.String("i", "dxf/test.dxf", "Input file path")
|
||||||
|
output = flag.String("o", "output.ngc", "Output file path")
|
||||||
direction = flag.String("d", "CCW", "Direction of path")
|
direction = flag.String("d", "CCW", "Direction of path")
|
||||||
|
analyze = flag.Bool("a", false, "Analyze contents of the file")
|
||||||
|
convert = flag.Bool("c", false, "Convert contents of the file")
|
||||||
//port = flag.Int("port", 3000, "an int")
|
//port = flag.Int("port", 3000, "an int")
|
||||||
//yesno = flag.Bool("yesno", true, "a bool")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
usr, _ := user.Current() // get user information
|
if flag.NFlag() == 0 { // if no flags are passed print usage
|
||||||
inipath := usr.HomeDir + "/.config/dxf2emc"
|
flag.Usage()
|
||||||
fmt.Println(inipath)
|
fmt.Println("Analyze", *analyze)
|
||||||
//fmt.Println(dxfutil.PathExists(inipath + "/dxf2emc.ini"))
|
fmt.Println("Flags", flag.NFlag())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if *convert {
|
||||||
|
fmt.Println("Convert was true")
|
||||||
|
}
|
||||||
|
iniMap := make(map[string]string)
|
||||||
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
dxfutil.Readini(iniMap, dir)
|
||||||
|
lines := dxfutil.GetLines(*input)
|
||||||
|
entities := dxfutil.GetEntities(lines)
|
||||||
|
if *analyze {
|
||||||
|
dxfutil.GetLayers(entities)
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Exit(1)
|
||||||
|
usr, _ := user.Current() // get user information
|
||||||
|
inipath := usr.HomeDir + "/.config/dxf2emc"
|
||||||
|
fmt.Println(inipath)
|
||||||
|
//fmt.Println(dxfutil.PathExists(inipath + "/dxf2emc.ini"))
|
||||||
//fmt.Println(dir)
|
//fmt.Println(dir)
|
||||||
//cwd, _ := os.Getwd() // get current working directory
|
//cwd, _ := os.Getwd() // get current working directory
|
||||||
iniMap := make(map[string]string)
|
|
||||||
//var inFile string
|
//var inFile string
|
||||||
/*
|
/*
|
||||||
if len(os.Args) == 2 {
|
if len(os.Args) == 2 {
|
||||||
@ -58,9 +80,7 @@ func main() {
|
|||||||
fmt.Println("Usage is: dxf2gcode -v")
|
fmt.Println("Usage is: dxf2gcode -v")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}*/
|
}*/
|
||||||
dxfutil.Readini(iniMap, dir)
|
|
||||||
lines := dxfutil.GetLines(*file)
|
|
||||||
entities := dxfutil.GetEntities(lines)
|
|
||||||
entities = dxfutil.GetEndPoints(entities)
|
entities = dxfutil.GetEndPoints(entities)
|
||||||
entities = dxfutil.GetOrder(entities)
|
entities = dxfutil.GetOrder(entities)
|
||||||
dxfutil.GenGcode(entities, iniMap["SAVEAS"])
|
dxfutil.GenGcode(entities, iniMap["SAVEAS"])
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package dxfutil
|
package dxfutil
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
@ -141,6 +140,22 @@ func GetEntities(list []string) ([]Ent){
|
|||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetLayers(e []Ent){
|
||||||
|
var layers []string
|
||||||
|
Search:
|
||||||
|
for i := range e {
|
||||||
|
if len(layers) == 0 {
|
||||||
|
layers = append(layers, e[i].G8)
|
||||||
|
continue Search
|
||||||
|
}
|
||||||
|
for j := range layers {
|
||||||
|
if e[i].G8 == layers[j]{ continue Search }
|
||||||
|
}
|
||||||
|
layers = append(layers, e[i].G8)
|
||||||
|
}
|
||||||
|
fmt.Println(layers)
|
||||||
|
}
|
||||||
|
|
||||||
func GetEndPoints (e []Ent) ([]Ent){
|
func GetEndPoints (e []Ent) ([]Ent){
|
||||||
// add error handling
|
// add error handling
|
||||||
for i := range e {
|
for i := range e {
|
||||||
|
|||||||
Reference in New Issue
Block a user