##  GridConvertDXF.py Version 1.00

##  Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc.

##  All rights reserved.

##  NOT FOR SALE. The software is provided "as is" without any warranty.

########################################################################

 

import macrolib.GridDXF

from macrolib.FileDefaults import job_Defaults_path

from macrolib.ExceptWarn import formatExceptionInfo

from param import Dialog, ResponseNotOK, Warning

import os

try:

    ## Dialog Box ######################

    dlg1 = Dialog("Convert a DXF file")

 

    dlg1.group_title("Parse DXF File")

    dlg1.file('import_file', os.path.join(job_Defaults_path(), "grids.dxf"), "Enter file name or browse")

 

    dlg1.group_title("Output File")

    dlg1.file_save('export_file', os.path.join(job_Defaults_path(), "grid_test.txt"), "Enter file name or browse")

    try:

        dd1 = dlg1.done()

    except ResponseNotOK:

        Warning(formatExceptionInfo())

    else:

        try:

            f = open(dd1['export_file'], 'w')

            f.write(macrolib.GridDXF.formatDXFpts(*(macrolib.GridDXF.parseDXFpts(dd1['import_file']))))

            f.close()

        except:

            Warning(formatExceptionInfo())

except:

    Warning(formatExceptionInfo())