PDA

View Full Version : Extracting Geometery from drawing


JOEVERSA
04-05-2005, 04:25 AM
I’m looking for information on to create a macro for extracting Geometery from a drawing. This geometry will be used for the creation of files that will be made available through our web site in either DWG or DXF formats.

This macro should be able to extract just the geometry from the drawing and
discard any dimensions or text that is not part of the individual drawing views.

I would appreciate any advice on macros or standard functions that are available to complete this task would be greatly appreciated. :)

Regards,

Joe

bfisher
04-05-2005, 09:16 AM
Joe,

The easiest way I can think of is to load the original ME-10 file, delete the text and dimensions, then save it back out in dxf format. Here's a simple macro that will do that. It assumes you have a file named "test" that contains text and dimensions on more than one part level. Good Luck,
Bruce

{ 05-apr-2005}

define Save_dxf_geo
local In_file
local Out_file

let In_file ('test')
let Out_file ('test.dxf')

load In_file
delete select dimensions global all confirm
delete select texts global all confirm end

store dxf all del_old Out_file


end_define {Save_dxf_geo}

JOEVERSA
04-08-2005, 07:54 AM
Thank you "bfisher" for supplying the Macro to get me started on this
task. I have taken your macro and revised to to include the deletion of the
drawing borders and leader lines. Since I'm relatively new to creating macros, can you please advise how I can revise the following macro to skip thru
the borders that are not applicable (Example: If drawing has '.border_B' the
macro will stop at (delete '.border_A') )

-------------------------------------------------------------
define Save_dxf_geo

local In_file
local Out_file

let In_file ('test')
let Out_file ('test.dxf')
delete ('.border_A')
delete ('.border_B')
delete ('.border_C')
delete select dimensions global all confirm
delete select LEADER_LINES global all confirm
delete select texts global all confirm end

store dxf all del_old Out_file

end_define {Save_dxf_geo}
-------------------------------------------------------------

I also need to load many (500+) files and repeat this process for each file.
I would appreciate any advise on how to modify the macro repeat for all files. :)

Regards,

Joe

bfisher
04-08-2005, 12:06 PM
Joe,

I split the task into two macros for simplicity, one to do the file clean-up and one to loop thru a list of files. The clean-up macro uses the trap_error command to prevent the problem of the macro stopping at the point of error. I've only coded for the three frame names you listed, but more could be easily added. In the calling macro, Clean_list_for_dxf, I've hard-coded the name of the list file as 'files.lst' and you can generate this list easily from a dos window with the following command: dir /b > files.lst. This will create the file with all the filenames in the directory listed one name per line. Be sure to edit that file with notepad or wordpad and delete the line "files.lst".

I suggest you test this with a small list first. Here are the two macros. You can save them as a single file, input that file from ME-10, then execute the macro Clean_list_for_dxf. Good Luck,

Bruce

{ 08-apr-2005}

define Clean_list_for_dxf
local save_name
local infile_name

delete all confirm
open_infile 1 'files.lst'
loop
read_file 1 infile_name
exit_if (infile_name='END-OF-FILE')
load infile_name
Clean_for_dxf
let save_name (infile_name+'.dxf')
store dxf all del_old save_name
delete all confirm
end_loop
close_file 1

end_define

define Clean_for_dxf
local In_file
local Out_file
local Is_err
local Bordername


delete select dimensions global all confirm
delete select texts global all confirm end
delete select LEADER_LINES global all confirm
let Bordername ('.border_A')
let Is_err (0)


trap_error
delete Bordername end
let Is_err (check_error)

if (Is_err)
let Bordername ('.border_B')
let Is_err (0)
trap_error
delete Bordername end
let Is_err (check_error)
if (Is_err)
{We still have an error and there is only one more choice }
let Bordername ('.border_C')
let Is_err (0)
trap_error
delete Bordername end
let Is_err (check_error)
end_if
end_if

end_define {Clean_for_dxf}