mgreathouse Posted November 1, 2016 Posted November 1, 2016 (edited) I'm having trouble with this LISP file that I'm trying to get to import DGNs and save out DWGs with AutoCAD MEP 2017. When I run the script, it shows this error: Unknown (command-s) failure. This happens before any kind of activity shows in CAD, so I'm assuming this is happening on the first (command-s) in the file. Any idea what might be causing this? The code I'm using is based on a version of this by M. Moolhuysen. EDIT: Probably worth noting that I restarted CAD and it seems to be happening after the first delay now, and I haven't change the code at all. (defun C:KURCONV (/ fil tx1 tx2 tx3 tx5) (setq tx1 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\dgnlist.txt" ;; list of file names to be imported tx2 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\Input DGNs\\" ;; input folder. tx3 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\Output DWGs\\" ;; output folder. ) (setq fil (open tx1 "r")) (setq tx5 (read-line fil)) ; repeats program until all lines from tx1 have been read in (while tx5 (command-s "_-DGNIMPORT" (strcat tx2 tx5) "" "" "") (command-s "._DELAY" 1000) (command-s "_Z" "e") (command-s "_-LAYOUT" "set" "20x29") (command-s "_MVIEW" "L" "ALL" "OFF" "") (command-s "_.MSPACE") (command-s "_Z" "e") (command-s "_.PSPACE") (command-s "_MVIEW" "L" "ALL" "ON" "") (setq tx5 (substr tx5 1 (- (strlen tx5) 4))) (command-s "_SAVEAS" "" (strcat tx3 tx5)) (command-s "._DELAY" 1000) (command-s "_-LAYOUT" "set" "model") (command-s "_DELETE" "all" "") (setq tx5 (read-line fil)) ) (close fil) ) Edited November 1, 2016 by mgreathouse Quote
Lee Mac Posted November 1, 2016 Posted November 1, 2016 Try the following instead: (defun c:kurconv ( / fil tx1 tx2 tx3 tx5 ) (setq tx1 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\dgnlist.txt" ;; list of file names to be imported tx2 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\Input DGNs\\" ;; input folder. tx3 "C:\\Users\\mgreathouse\\Desktop\\DGN to DWG\\Output DWGs\\" ;; output folder. ) (if (setq fil (open tx1 "r")) (progn (while (setq tx5 (read-line fil)) (command "_.-dgnimport" (strcat tx2 tx5) "" "" "" "_.delay" 1000 "_.zoom" "_E" ) (setvar 'ctab "20x29") ;; Assumes layout exists! (command "_.mview" "_L" "_OFF" "_All" "" "_.mspace" "_.zoom" "_E" "_.pspace" "_.mview" "_L" "_ON" "_All" "" "_.saveas" "" (strcat tx3 (vl-filename-base tx5)) "_.delay" 1000 ) (setvar 'ctab "Model") (command "_.erase" "_All" "") ) (close fil) ) (princ (strcat "\nUnable to read " tx1)) ) (princ) ) Quote
mgreathouse Posted November 1, 2016 Author Posted November 1, 2016 That works beautifully! Once I get all these DGN's converted I'm going to do a little research on some of the lisp functions you used and figure out the differences and why it's better to do it that way. Should keep me busy tonight and help me learn a little more since I'm pretty new to AutoLISP. Thanks a lot! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.