Jump to content

Recommended Posts

Posted

hi,

i Want to write ".txt" or ".csv" file from autocad. the problem is which flag i use for write the file . i.e. my file maybe new or Existing. if file is already exist then data must be append otherwise create a new file...

 

i user following syntax

 

(setq tempfile (getfiled "Save File As" "c:\" "txt;csv;*" 1))

Posted

Not sure if this will help, I haven't used getfiled very much, but I did notice one thing; you have a single backslash, which would mess up your code.

 

Take a look in the help file for AutoLISP control codes. The short version is: ever use "\n" to create a new line? It's similar to that. In terms of directories, since most have a backslash in them, you have two options; use a forwardslash in place of the backslash, or, use the backslash as a control code to input a backslash, id est, "\\".

 

Hope this helps. ^.^

Posted

thanks for reply "freerefill"

you r right. it is mistake of typing. i already use "\\".

Posted

I would use bit code 9 (8+1) for existing/or create new.

Posted

If it's just a .TXT or a .CSV and you are saving it to your C drive couldnt you just...

 

(setq flname (strcat "C:\\" (getstring "Enter The name of your file (Specify .TXT or .CSV): ")))
(setq file (open flname "a"))
(write-line "Whatever you want" file)
(close file)

 

in this case it will create new if it doesn't exist or append if it does...

 

just a thought

Posted
If it's just a .TXT or a .CSV and you are saving it to your C drive couldnt you just...

 

(setq flname (strcat "C:\\" (getstring "Enter The name of your file (Specify .TXT or .CSV): ")))
(setq file (open flname "a"))
(write-line "Whatever you want" file)
(close file)

in this case it will create new if it doesn't exist or append if it does...

 

just a thought

 

yes, but you would have to specify the folders/sub-folders and full path name.

 

Getfiled allows you to browse various folders and will return the resultant filename.

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...