CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Data Exchange

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-27-2007, 12:05 PM
mambrose mambrose is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Batch translate compressed files to DXF

I need a macro that takes all files in a dir and loads them in ME10 and then store them with same name +.dxf.
Reply With Quote
  #2  
Old 02-27-2007, 02:05 PM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Batch translate compressed files to DXF

See the recent discussion at http://cocreateusers.org/forum/showthread.php?t=6134
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
  #3  
Old 03-01-2007, 05:40 AM
mambrose mambrose is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Re: Batch translate compressed files to DXF

What I have are directories full of compressed mi files with no mi extension, so I can not use the batch translate MI to DXF in the provided translator. I need a macro that will translate these files to the standard model interface mi file and also add the mi extension. At that point I can use the batch translation function of the translator.
Reply With Quote
  #4  
Old 03-02-2007, 12:18 AM
ofischer ofischer is offline
Registered User
 
Join Date: Jan 2007
Location: France
Posts: 55
Re: Batch translate compressed files to DXF

Hello,
Test this macro. You must hace a repertory 'C:\temp'
Input the macro file and run the macro with a the directory of the drawing for parameter:
creerdxf 'C:\xxx\xxx\drawing_repertory'
DEFINE net_fin_lig
LOCAL LONGLIG
LOOP
LET LONGLIG (LEN(LIGNE))
LET CARACT (SUBSTR LIGNE LONGLIG 1)
EXIT_IF ((CARACT <> ' ') AND (CARACT <> ''))
IF (CARACT = ' ')
LET LIGNE (SUBSTR LIGNE 1 (LONGLIG-1))
END_IF
END_LOOP
END_DEFINE

DEFINE Menage
CLEAN_DRAWING CLEAN_CLEAN_GAPS GLOBAL 0.01 CONFIRM END
CLEAN_DRAWING CLEAN_STACKED_GEOMETRY GLOBAL 0.01 CONFIRM END
CLEAN_DRAWING CLEAN_STAGGERED_GEOMETRY GLOBAL 0.01 CONFIRM END
CLEAN_DRAWING CLEAN_DUPLICATE_GEOMETRY GLOBAL 0.01 CONFIRM END
END_DEFINE

DEFINE Change_police_cotation_et_texte
CHANGE_DIM_TEXTS DIM_ALL FONT 'hp_i3098_v' SELECT DIMENSIONS ALL CONFIRM
CHANGE_TEXT_FONTNAME 'hp_i3098_v' SELECT GLOBAL TEXTS ALL CONFIRM
END_DEFINE

DEFINE creerdxf
LOCAL Charge_dir
LOCAL Sauve_dir
LOCAL Tmp_dir
LOCAL REPBASE
LOCAL DAT
LOCAL TIM
LET Tmp_dir 'c:\temp\'
READ 'Identifiez le rÅpertoire È traiter: ' REPBASE
LET Charge_dir (REPBASE)
RUN ('mkdir ' + (Charge_dir + '\dxf'))
LET Charge_dir (Charge_dir + '\')
LET Sauve_dir (Charge_dir + 'dxf\')
RUN ('date /T > ' + (Tmp_dir + 'datetime.txt'))
OPEN_INFILE 2 (Tmp_dir + 'datetime.txt')
READ_FILE 2 DAT
RUN ('time /T >> ' + (Tmp_dir + 'datetime.txt'))
READ_FILE 2 TIM
CLOSE_FILE 2
OPEN_OUTFILE 8 APPEND (Sauve_dir + 'plan_traite.txt')
OPEN_OUTFILE 7 APPEND (Sauve_dir + 'plan_erreur_conversion.txt')
WRITE_FILE 7 '********************************************'
WRITE_FILE 7 ' '
WRITE_FILE 7 ('Traitement du: ' + DAT + ' à ' + TIM )
WRITE_FILE 7 ' '
WRITE_FILE 7 '********************************************'
WRITE_FILE 8 '********************************************'
WRITE_FILE 8 ' '
WRITE_FILE 8 ('Traitement du: ' + DAT + ' à ' + TIM )
WRITE_FILE 8 ' '
WRITE_FILE 8 '********************************************'
RUN ('DIR *.* /B ' + Charge_dir + ' > ' + Tmp_dir + 'liste.txt') {Liste courte du rep à traiter}
OPEN_INFILE 1 (Tmp_dir + 'liste.txt')
READ_FILE 1 LIGNE
IF (LIGNE = 'END-OF-FILE')
DISPLAY ('ERREUR: Aucun plan È migrer !!!!')
ELSE
CLOSE_FILE 1
OPEN_INFILE 1 (Tmp_dir + 'liste.txt')
LOOP
READ_FILE 1 LIGNE
EXIT_IF (LIGNE = 'END-OF-FILE')
IF ((LIGNE <> '') AND (LIGNE <> 'workfile') AND (LIGNE <> 'hp_catlock') AND (LIGNE <> 'hp_catfile'))
net_fin_lig
EDIT_PART TOP
DELETE ALL CONFIRM END
TRAP_ERROR
LOAD (Charge_dir + LIGNE)
INQ_SELECTED_ELEM ALL END
IF ((INQ 14) <> 0)
IF (CHECK_ERROR )
END
BEEP
WRITE_FILE 7 ('ERREUR: lecture ME10: '+ Charge_dir + LIGNE )
END
END_IF
SPLINE_CONVERSION ON
EDIT_PART TOP
TRAP_ERROR
STORE DXF ALL DEL_OLD (Sauve_dir + LIGNE){}
IF (CHECK_ERROR )
END
BEEP
WRITE_FILE 7 ('ERREUR: sauvegarde dxf : '+ Charge_dir + LIGNE )
END
ELSE
WRITE_FILE 8 ('sauvegarde dxf : '+ Charge_dir + LIGNE )
END_IF
ELSE
BEEP
WRITE_FILE 7 ('ERREUR: fichier vide: '+ Charge_dir + LIGNE )
END_IF
EDIT_PART TOP
DELETE ALL CONFIRM END
TRAP_ERROR
ELSE
WRITE_FILE 7 ('ERREUR: au chargement du fichier: '+ Charge_dir + LIGNE )
END_IF
EXIT_IF (LIGNE = 'workfile')
EXIT_IF (LIGNE = 'hp_catlock')
EXIT_IF (LIGNE = 'hp_catfile')
END_LOOP
END_IF
EDIT_PART TOP
DELETE ALL CONFIRM END
RUN ( 'del ' + (Tmp_dir + 'liste.txt'))
RUN ( 'del ' + (Tmp_dir + 'datetime.txt'))
CLOSE_FILE 1
WRITE_FILE 8 '********************************************'
CLOSE_FILE 8
WRITE_FILE 7 '********************************************'
CLOSE_FILE 7
END_DEFINE
Reply With Quote
  #5  
Old 03-02-2007, 11:35 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: Batch translate compressed files to DXF

Here is a macro which I think will do what you want. It will attempt to load all the files in the current directory and save them as MI with a ".mi" appended to the loaded file name. You can set the current directory by opening any file in a directory before running the macro or using the CURRENT_DIRECTORY command. Or you can replace the '.' in the CATALOG line of the macro with a directory path. If you want to convert directly to DXF then comment the STORE MI... line and uncomment the STORE DXF... line.

It is not very sophisticated. It will convert all the files it can load and does not check the type. But based on your description of what you have I think it will work. It will only convert the files in the specified directory, it will not convert any files in subdirectories under that directory.
Edit: The original macro was corrected per the discussion below.
Code:
DEFINE Convert_all_to_mi
  { Convert all files in current directory to MI files}
  LOCAL Tmp_file_name
  LOCAL File_name
  LOCAL Fileline
  LET Tmp_file_name (MAKE_TMP_NAME)
  CATALOG_LAYOUT (RPT ' ' 256) END
  DEFINE_CATALOG 'file_name' 1 1
  CATALOG '.' SELECT 'FILE_TYPE' 'Reg' DEL_OLD Tmp_file_name
 
  OPEN_INFILE 1 Tmp_file_name
  { Read and discard the first 4 lines which are header info }
  READ_FILE 1 Fileline
  READ_FILE 1 Fileline 
  READ_FILE 1 Fileline
  READ_FILE 1 Fileline
 
  { Attempt to load each file in the list and save as MI if successful }
  LOOP
    READ_FILE 1 Fileline
  EXIT_IF (Fileline='END-OF-FILE')
    LET File_name (TRIM Fileline)
    RESET_SYSTEM CONFIRM
    TRAP_ERROR
    LOAD File_name
    IF (CHECK_ERROR)
      DISPLAY_NO_WAIT ('Could not load file: ' + File_name)
    ELSE
      STORE MI ALL DEL_OLD (File_name + '.mi') 
      {STORE DXF V1018 ALL DEL_OLD (File_name + '.dxf')} 
      { to delete the original file uncomment the following line }
      {PURGE_FILE File_name CONFIRM}
    END_IF
  END_LOOP
  CLOSE_FILE 1
  PURGE_FILE Tmp_file_name CONFIRM END
END_DEFINE
__________________
John Scheffel
Reply With Quote
  #6  
Old 03-04-2007, 09:31 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 756
Re: Batch translate compressed files to DXF

do you really need a MACRO?


why not using a shell script / Batch_file mode

Code:
 dxfdwg [-option] [-t] [-k] [-b batch_file] [-e config_file] [-f source [dest [log]]]
dxfdwg -o -f infile-without-extension out-file.dxf

just tested:
dxfdwg.exe -o -f d:\A4 d:\a4.2.dxf
works fine.

If with the -b batch_file mode its working fine.


I assume the -o option is unkown to you?
Reply With Quote
  #7  
Old 03-05-2007, 10:39 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: Batch translate compressed files to DXF

Quote:
Originally Posted by Wolfgang View Post
do you really need a MACRO?

why not using a shell script / Batch_file mode....
The problem with this suggestion is that dxfdwg.exe does not work on compressed MI files even if you specify the file name. I tried it using version 2006 and got the message below.

"Not an ascii MI file!'
__________________
John Scheffel
Reply With Quote
  #8  
Old 03-27-2007, 09:45 AM
mambrose mambrose is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Re: Batch translate compressed files to DXF

I tried this macro and it loads the first file in the directory and then saves that file to every other filename in the directory if that makes sense. It never deletes the first file and load the next.
Reply With Quote
  #9  
Old 03-27-2007, 11:17 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: Batch translate compressed files to DXF

Quote:
Originally Posted by mambrose View Post
I tried this macro and it loads the first file in the directory and then saves that file to every other filename in the directory if that makes sense. It never deletes the first file and load the next.
I did run some quick tests on this macro but did not check the resulting MI files. The problem was that I forgot to start a new drawing before each LOAD command (RESET_SYSTEM) so loading failed after the first load. I have corrected the macro in the above post so it should work correctly now.

You did not mention that you wanted to delete the original files. I added a commented line to the macro to do that, but be aware that if the conversion does not work correctly you will still lose the original files. I would recommend against uncommenting it.
__________________
John Scheffel
Reply With Quote
  #10  
Old 03-27-2007, 11:26 AM
mambrose mambrose is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Re: Batch translate compressed files to DXF

Thanks John for all of your help...I have been in an out of town the past few weeks and did not have a chance to try your previous macro until today. Where might I find the updated macro?

Thanks again,
Mark
Reply With Quote
  #11  
Old 03-27-2007, 11:30 AM
mambrose mambrose is offline
Registered User
 
Join Date: Feb 2007
Posts: 6
Re: Batch translate compressed files to DXF

I see that you updated the original in the previous post. I works great...Thanks again, this will save me a lot of time.

Mark
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:14 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: