Author Topic: SAving to .WMF  (Read 2558 times)

0 Members and 1 Guest are viewing this topic.

lispman21

  • Guest
SAving to .WMF
« on: August 28, 2006, 10:52:15 AM »
I have some dxf files and i know in order to save them as wmf files you can either export them or use the wmfout command.  Is there a way to get a lisp program to open up files in a directory and save them as wmf's.  All I need is save all the dxf files to wmf files.

nivuahc

  • Guest
Re: SAving to .WMF
« Reply #1 on: August 28, 2006, 11:24:16 AM »
Why not just script it?

lispman21

  • Guest
Re: SAving to .WMF
« Reply #2 on: August 28, 2006, 11:37:43 AM »
Script will work too.  Here is the script I have but it doesn't work.  Feel free to change waht you need.


Code: [Select]
(defun c:GenScr (/ dwgPath dwgList dwgName numDwgs count scrFile)
;;; Path should be like "c:\\projects\plots\\" or "c:/projects/plots/"
;;; Substitute your path here.
(setq dwgPath "C:\\Documents and Settings\\laoom\\Desktop\\New Folder\\" ; sets the path
dwgList (vl-directory-files dwgPath "*.Dxf") ; get the list of all the dxf's
)
(if dwgList ; if dwg files exists there
(progn
(setq numDwgs (length dwgList) ; number of drawings
count 0 ; initiate counter
scrFile (open (strcat dwgPath "Runme.scr") "w") ; open a script file in the same folder
)
(repeat numDwgs ; for all the drawings
(setq dwgName (strcat "\"" dwgPath (nth count dwgList) "\""))  
(write-line ".Open" scrFile) ; write to script file
(write-line dwgName scrFile)  
;;;
;;; Preset the dxf file format before you proceed.
;;; May require minor modification depending on you
;;; AutoCAD version Notice the two spaces after dxfout
;;; in the following line acts like <enter>.This will
;;; accept the default file name and default format
(write-line ".wmfout  " scrFile)
  (write-line "ALL" scrFile)
;;; Better to save the drawing for uninterrupted scripting
;(write-line ".Qsave" scrFile)
  (write-line ".close" scrFile)
(setq count (1+ count)); next dwg
)
(close scrFile); close when done
;;; Make sure that the current dwg won't prompt for
;;; save changes!
(command ".script" (strcat dwgPath "Runme.scr")); run the script
); progn
); if
(princ)
); defun
« Last Edit: August 28, 2006, 11:39:03 AM by lispman21 »

nivuahc

  • Guest
Re: SAving to .WMF
« Reply #3 on: August 28, 2006, 12:03:47 PM »
Code: [Select]
(defun c:GenScr (/ dwgPath dwgList dwgName numDwgs count scrFile)
;;; Path should be like "c:\\projects\plots\\" or "c:/projects/plots/"
;;; Substitute your path here.
  (setq dwgPath "C:\\test\\"
; sets the path
dwgList (vl-directory-files dwgPath "*.Dxf")
; get the list of all the dxf's
  )
  (if dwgList ; if dwg files exists there
    (progn
      (setq numDwgs (length dwgList) ; number of drawings
    count   0 ; initiate counter
    scrFile (open (strcat dwgPath "Runme.scr") "w")
; open a script file in the same folder
      )
      (repeat numDwgs ; for all the drawings
(setq dwgName (strcat "\"" dwgPath (nth count dwgList) "\""))
(write-line ".Open" scrFile) ; write to script file
(write-line dwgName scrFile)
;;;
;;; Preset the dxf file format before you proceed.
;;; May require minor modification depending on you
;;; AutoCAD version Notice the two spaces after dxfout
;;; in the following line acts like <enter>.This will
;;; accept the default file name and default format
(write-line ".wmfout " scrFile)
(write-line "ALL " scrFile)
;;; Better to save the drawing for uninterrupted scripting
;(write-line ".Qsave" scrFile)
(write-line ".close" scrFile)
(write-line "Y" scrFile)
(setq count (1+ count)) ; next dwg
      )
      (close scrFile) ; close when done
;;; Make sure that the current dwg won't prompt for
;;; save changes!
      (command ".script" (strcat dwgPath "Runme.scr")) ; run the script
    ) ; progn
  ) ; if
  (princ)
) ; defun

EDIT: oops, posted too soon
« Last Edit: August 28, 2006, 12:07:55 PM by nivuahc »

lispman21

  • Guest
Re: SAving to .WMF
« Reply #4 on: August 28, 2006, 12:07:31 PM »
The code did not save as wmf and not sure why.  It really didn't do anything.  Stioll only showed one file and that was a dxf.

nivuahc

  • Guest
Re: SAving to .WMF
« Reply #5 on: August 28, 2006, 12:08:52 PM »
Sorry 'bout that, it had a tiny typo. I edited it and it should work just fine now.

nivuahc

  • Guest
Re: SAving to .WMF
« Reply #6 on: August 28, 2006, 12:10:21 PM »
And, in case you're wondering, the only lines I changed were:

Code: [Select]
(write-line ".wmfout " scrFile)

(write-line "ALL " scrFile)

(write-line "Y" scrFile)

lispman21

  • Guest
Re: SAving to .WMF
« Reply #7 on: August 28, 2006, 01:00:52 PM »
Works perfectly now.  Thanks for your help.

nivuahc

  • Guest
Re: SAving to .WMF
« Reply #8 on: August 28, 2006, 01:02:04 PM »
My pleasure.

'tweren't nothin' :)