Jump to content

Output to Text File Without Dialog Box?


Recommended Posts

Posted

I have this snippet of code where you can output a file:

 

 (if (setq fn
            (getfiled "Save layer list as"
                      (strcat (vl-filename-base (getvar "dwgname")) ".txt")
                      "txt"
                      1
            )
     )
   (if (layer-list-fprint fn)
     (princ "\nLayer list created.")
     (princ "\nError: Layer list not created!")
   )
 )
 (princ)

What I want to do is to automatically output a text file with the file name the same as the .dwg (but with a ".txt" extension) and overwrite an existing file in one exists.

 

Can I do that without the dialog?

 

Greg

Posted

Getfiled is calling the dialog box, look at (getvar "dwgprefix") you can hard code the txt file to be in the same place as the dwg or put it where ever you like.

 

(setq fname (strcat (getvar "dwgprefix") (getvar "dwgname") ".txt"))

another example 
; check that pdf directory exists
(setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
(if (= (vl-file-directory-p dwgpre) nil)
(vl-mkdir dwgpre)
)
(setq pdfname (strcat (getvar "dwgprefix") "pdf\\" dwgname "-" (getvar "ctab")))

Posted

That worked great BIGAL and thanks!

 

Also, I appreciate the bonus code.

 

Greg

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...