(defun C:MicroStationToAutoCAD (/ fil tx1 tx2 tx3 tx4 tx5)
(setq tx1 "C:\\Drawing Conversion\\List.txt" ; File holding a list of MicroStation drawings to be imported
tx2 "C:\\Drawing Conversion\\In\\" ; Input folder
tx3 "C:\\Drawing Conversion\\Out\\" ; Output folder
tx4 "Default" ; Drawing model name
)
(setvar "DGNIMPORTMODE" 1)
(setq fil (open tx1 "r")
tx5 (read-line fil))
(while tx5
(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)
)
(setq tx1 (load (findfile ".\\List.txt") nil)
tx2 ((load (findfile ".\\In\\") nil)
tx3 (load (findfile ".\\Out\\") nil)
Thanks for responding kpblc.Hmmm... As fas as I know LISP can't define his loading path. You can automatically load lisp through at least 3 ways. How do you loading lisp? By Startup suite? By MNL? By acaddoc.lsp?
I didn't frame my question properly.
So there would be no changes to the LISP file when moving computers. At the moment, in your code, you would have to input the path "C:\\Drawing Conversion".
This is because paths are relative to the LISP file and are in the same directory. The automatic load of the LISP file takes care of the path. Is this possible?
Not that I don't want to do it but will forget at the time and may or may not be able to decipher what has to be done.
I'll try your code at some stage, thanks for that.
(setq pth (vl-filename-directory strcat tx1 "\\")
Thanks for providing the code.
I tried to run it after adding the path. The program was stuck though, whatever it was processing required a lot of memory. There was no error message in the command line.
The way I added the support path was: Tools, Options, Support File Search Path, Add. Added "C:\Drawing Conversion". Tried moving to the top, restarting, etc, no luck.
The only thing I could think of was adding "\\" after the "list.txt" using "strcat" ... but got an error message.Code: [Select](setq pth (vl-filename-directory strcat tx1 "\\")
PKENEWELL, I tried to send a sample via PM but there was no option to attach.
Given I don't have ownership of the drawings, I can't post them online.
I did find a site which has sample DGN drawings available, please see link:
https://www.q-cad.com/samples/microstation-2d/microstation-2d-samples/ (https://www.q-cad.com/samples/microstation-2d/microstation-2d-samples/)
Thanks very much PKENEWELL, this works now.
I think your previous shorter version works as well.
Long story, but the issue was with the text file, as I discovered having issues with the initial code, once working, then not. It took me a while to figure it out. I was using Excel to dump the drawing list data into the text file and AutoCAD didn't seem to accept it.
Initially I tried the latest code, that did not work, then after working out the issue, your code did work and the previous shorter version seems to work as well.
Sorry if this wasted your time, but it may be useful for someone else.