DGN to DWG LISP Program Not Working

DGN to DWG LISP Program Not Working

jalwgis
Contributor Contributor
1,961 Views
7 Replies
Message 1 of 8

DGN to DWG LISP Program Not Working

jalwgis
Contributor
Contributor

I'm getting error when running a LISP program to batch convert a number of DGN files to DWG.

The first error I got was when I loaded the lsp file. The second error I got was when I tried to execute the lsp file.

I've attached the error files and lsp file.

Any help is appreciated.

 

0 Likes
Accepted solutions (4)
1,962 Views
7 Replies
Replies (7)
Message 2 of 8

devitg
Advisor
Advisor

Please upload a sample.dgn file 

0 Likes
Message 3 of 8

devitg
Advisor
Advisor
Accepted solution

You lost 2 double quotes  search "

 

(setq tx1 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\DGN-LIST.txt" ;; example variable: file holding a list of *.dgn's names to be imported.
tx2 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\"" ;; example variable: input folder.
tx3 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\DWG\"" ;; example variable: output folder.
tx4 "Default" ;; example variable: drawing model name
)

Message 4 of 8

hak_vz
Advisor
Advisor
Accepted solution
(defun C:DGN2DWG_batch_rev (/ fil tx1 tx2 tx3 tx4 tx5)
 (setq tx1 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\DGN-LIST.txt" 
       tx2 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\" 
       tx3 "R:\Scanned_Files\Scanned_Files_TUL\DWG's\RW 18R-36L Safety Area 2013 Asbids\RW 18R-36L Safety Area 2013 Asbids\As-Bid CAD files\DWG\"
       tx4 "Default"
 )
 (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" "2000(LT2000)" (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)
)

Set correct paths, and don't use ' in directory name (dwg's). Try to run and report result.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 8

devitg
Advisor
Advisor
Accepted solution

Check if it work 

Message 6 of 8

jalwgis
Contributor
Contributor

Thank you for your help. I will test and let you know if it works.

0 Likes
Message 7 of 8

jalwgis
Contributor
Contributor

Why the two double quotes on variables TX2 & TX3 and not TX1?

0 Likes
Message 8 of 8

jalwgis
Contributor
Contributor
Accepted solution

I got the script to work. Gave me the same error message after adding the double quotes. Moving the drawings to another directory that didn't have the ' in DWG'S worked. Here is the script after making the changes:

 

(defun C:DGN2DWG_batch_rev-modified (/ fil tx1 tx2 tx3 tx4 tx5)
(SETQ TX1 "U:\\DWGS\\RW 18R-36L Safety Area 2013 Asbids\\DGN-LIST.txt"
;; example variable: file holding a list of *.dgn's names to be imported.
;; Added another forward slash- 12-9-2019
TX2 "U:\\DWGS\\RW 18R-36L Safety Area 2013 Asbids\\"
;; example variable: input folder.
;; Added another forward slash and deleted double quote at the end - 12-9-2019
TX3 "U:\\DWGS\\RW 18R-36L Safety Area 2013 Asbids\\DWG\\"
;; example variable: output folder.
;; Added another forward slash and deleted double quote at the end - 12-9-2019
TX4 "Default"
;; example variable: drawing model name
)

 

Thanks for your help!

 

 

0 Likes