Hi All,
My work needs to convert thousands of DGN files to DWG. We are using AutoCAD 2012. Is it possible to batch convert dgn files with a LISP and a mapping file? Anyone have a LISP for this?
Any help is appreciated.
Arul
I suspect that the action of opening a new drawing stops the execution of the lisp routine in the original drawing unttil the focus is returned to the original drawing. This is the reason I use a different mode for DGNIMPORT in AutoCAD 2012. I think that I'm not able to find a solution for AutoCAD version 2011.
first thankx sir
i try this tool in autocad 2012 but it is not working sir,some option is comming (Enter filename for DGN import:)
i need thiis lisp ,so plse reply send me my mail ,what iam do,
thanking you sir
mohan
I've managed to batch convert multiple DGN files using 3rd party software.
After, I've written my lisp
... (command "-mapimport" "DGN_V7_V8" nn3 "Y" "c:\\hatch.ipf" "I" "yes" "") ...
and tested it on one DGN
i've bought and installed this:
http://www.cadfx.com/batchscr/
and applyed my lisp on bunch of empty DWG files named as DGN files so when using DWGNAME variable i managed to import dgn...
I updated the paths for tx1, tx2 and tx3. I left tx4 as "default". When I tried running the lsp, I got the error msg:
Command: DGNI
; error: bad argument type: FILE nil
What am I doing wrong?
Thanks!!
Dear Sir, I found your message dated 27/11/2014 but I don't know how to contact you and send the dgn file to you?! Pl help! Thx!
;* DGN_batch_modified.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings ; Start command by typing DGNI ; ; Make the necessary adjustments to the following variables: ; --------------------------------------------------------- ; tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported, ; names of *.dgn drawings may be written without extension, as well as with extension, ; in plain text format, no return after the last line. ; tx2 = the path for the input folder, containing the actual *.dgn files to import. ; tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved, ; (routine assumes that the *.dwg files do not exist yet) ; tx4 = name of the drawing model to import ; ; ; The routine reads drawing names from the file given in tx1 line-for-line. ; In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing, ; does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3, ; and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop. ; ; The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation ; between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings). ; ; The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma, ; I advise to rename drawings having this issue. ; ; Written by M. Moolhuysen. Modified by C. Matthews ; ; This software may not be sold as commercial product or included as part of a commercial product. (defun C:DGNI (/ fil tx1 tx2 tx3 tx4 tx5) (setq tx1 "C:\\Users\\yourname\\Desktop\\Batch_Folder\\files.txt" ;; example variable: file holding a list of *.dgn's names to be imported. tx2 "C:\\Users\\yourname\\Desktop\\Batch_Folder\\Input_Folder\\" ;; example variable: input folder. tx3 "C:\\Users\\yourname\\Desktop\\Batch_Folder\\Output_FOlder\\" ;; example variable: output folder. tx4 "Default" ;; example variable: drawing model name ) (setvar "DGNIMPORTMODE" 1) (setq fil (open tx1 "r") tx5 (read-line fil)) ; repeats program until all lines from the list with *.dgn drawing names are read. (while tx5 ; strips an extension with length of 3 characters from the drawing name, if present. (if (wcmatch tx5 "*`.???") (setq tx5 (substr tx5 1 (- (strlen tx5) 4))) ) (command "_UNDO" "_MARK" "_-DGNIMPORT" (strcat tx2 tx5) tx4 "" "" "_ZOOM" "_E" "._DELAY" 500 "_SAVEAS" "2007(LT2007)" (strcat tx3 tx5) ) (command "_ERASE" "ALL" "") ;erases everything on the page after the save (command "_.purge" "_all" "" "_no") ;purges everything so you don't carry it over to the next drawing (command "_.purge" "_regapp" "" "_no") (command "_QNEW") ;opens a new drawing (setq tx5 (read-line fil)) ) (close fil) (command "_QUIT" "_Y") (princ) )
what we need is a link with a folder that contains all the elements needed for this usful tool. compleate with read me instructions, so people only need to coppy the file locations in properties and the use find replace in note pad, to modify the lisp.
also instructions on how to quickly jenerate that first list with the names, otherwise we spend only a little more time creating the lisp than we would other wise spend doing it manualy
you know... for the neafights
I just wanted to say this change you made helped me out a lot. Before I could only do one conversion at a time which was a pain.. It kept asking me if i wanted to undo all y or n. Also, an easy way to get the files you want is to go to cmd ( command prompt) , go to the directory you are needing to be in with the cd c:\"directory name" and type dir /b/n > filename.txt this clears all the dates and stuff off and only list the files. I know this post is old but it has saved me so much time I wanted to say thank you! to both of you for making this conversion lisp.
From the old DOS era:
cd c:\data\acad\blocks\verbindingsartikelen >>>>>>>>> Change to the top subdir of your DNG files. dir *.dng /s /b > c:\data\acad\dnglst.txt >>>>>>>>>>> Change where you want to store your TXT file
Save above lines to a file called DirLST.bat in a convenient place. Once prepared double click on DirLST.bat from Explorer. It will create the file dnglst.txt , which is immediately usable in the conversion lsp, containing all *DNG files complete with pathnames down to all subdirectories below the original
Cannot seem to get working. I am sure I am doing something wrong. Please advise.
Running the lsp. Auto cad opens and the select file window comes up to the last location where files were opened from.
No DGNIMPORT window, just the above.
I can run DGNIMPORT directly from command line and import one file at a time with no issue.
I have placed the below LSP and place it in c:\programdata\audodesk
I have built two folders in the same location: Dgn-input and Dwg-output
I have placed all DGN's that I want to convert into the Dgn-input folder
I have made a flat text file of DGN files and saved it as Dgn-names in c:\programdata\audodesk
I can save each imported file to DWG.
I cannot select multiple DGN's within Acad.
;DGNIMPORT.LSP - Converts a list of Microstation *.dgn drawings into AutoCAD *.dwg drawings
; Start command by typing DGNI
;
; Make the necessary adjustments to the following variables:
; ---------------------------------------------------------
; tx1 = path and name of a file that holds a list with names for all the *.dgn's to be imported,
; names of *.dgn drawings may be written without extension, as well as with extension,
; in plain text format, Do NOT have a return after the last line.
; tx2 = the path for the input folder, containing the actual *.dgn files to import.
; tx3 = the path for the output folder, where the drawings converted into *.dwg will be saved,
; (routine assumes that the *.dwg files do not exist yet)
; tx4 = name of the drawing model to import
;
;
; The routine reads drawing names from the file given in tx1 line-for-line.
; In each loop it performs a DGNIMPORT from the folder given as tx2 into the existing AutoCAD drawing,
; does a Zoom Extends, saves the converted drawing result as *.dwg in the folder given as tx3,
; and finally restores the drawing to its original state, ready to receive the next DGNIMPORT loop.
;
; The DELAY command for 1000 milliseconds (1 second) is needed to provide sufficient separation
; between the DGNIMPORT and SAVEAS processes (otherwise it starts to mix up drawings).
;
; The DGNIMPORT command trips when the name of the *.dgn to be imported contains a comma,
; I advise to rename drawings having this issue.
;
(defun C:DGNI (/ fil tx1 tx2 tx3 tx4 tx5)
(setq tx1 "C:\\ProgramData\Autodesk\Dgn-names.txt" ; example variable: file holding a list of *.dgn's names to be imported.
setq tx2 "C:\\ProgramData\Autodesk\Dgn-input"\ ; example variable: input folder.
setq tx3 "C:\\ProgramData\Autodesk\Dwg-output"\ ; example variable: output folder.
setq tx4 "Default" ; example variable: drawing model name )
(setvar "DGNIMPORTMODE" 1)
(setq fil (open tx1 "r") tx5 (read-line fil)) ; repeats program until all lines from the list with *.dgn drawing names are read.(while tx5 strips an extension with length of 3 characters from the drawing name, if present.
(if (wcmatch tx5 "*`.???")
(setq tx5 (substr tx5 1 (- (strlen tx5) 4))))
(command "_UNDO" "_MARK" "_-DGNIMPORT" (strcat tx2 tx5)tx4 "" ""
"_ZOOM" "_E"
"._DELAY" 1000
"_SAVEAS" "2007(LT2007)" (strcat tx3 tx5)
"_UNDO" "_BACK")
(setq tx5 (read-line fil)))
(close fil)
(command "_QUIT" "_Y")
(princ))
Hi Gabriel. Can you write this batch lisp? The DGN is not supported by this chat. Can you catch the file in my Drive?
https://drive.google.com/file/d/1IfRTG9qQYfqFWHDqqaOxrTPHmfyXQo3M/view?usp=share_link
Many thanks!
Can't find what you're looking for? Ask the community or share your knowledge.