Author Topic: output a .txt file  (Read 7686 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« on: April 28, 2005, 12:34:04 PM »
i know this is possible. i want to output a .txt file with lisp. in that file it should contain text that i type in when the lisp file prompts me to. in other words i run a routine then the routine prompts me to write something in and it repeats this until i have provided all the information. then it writes a .txt file. the purpose for this is my idea of user interaction when making a plot. before the plot command executes this routine should pop-up and ask certain questions and after the questions are answered (by input from user) then it writes the text file. can somebody guide to the right direction?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
output a .txt file
« Reply #1 on: April 28, 2005, 12:57:47 PM »
To open a file for writing;
Code: [Select]
(setq file_open (open "c:\\name.txt" "w"))
then you want to write to it using;
Code: [Select]
(write-line "some string" file_open)
when you're done make sure you close the file
Code: [Select]
(close file_open)

that's a start anyway.
TheSwamp.org  (serving the CAD community since 2003)

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #2 on: April 28, 2005, 01:02:39 PM »
thanks, ill be be back later with a routine..hopefully......

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
output a .txt file
« Reply #3 on: April 28, 2005, 01:15:38 PM »
I'll be waiting... :)
TheSwamp.org  (serving the CAD community since 2003)

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #4 on: May 03, 2005, 12:36:06 PM »
UM...HOW do i make it so another lisp routine runs after i plot. in other words after i plot a drawing then this new command runs directly after that. and how do i get strings of information on the plotter's page setups? what im looking for is to get the size of the sheet of the current drawing that was sent to the plotter.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
output a .txt file
« Reply #5 on: May 03, 2005, 12:50:13 PM »
Are you thinking "plot log" ??
TheSwamp.org  (serving the CAD community since 2003)

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #6 on: May 03, 2005, 01:49:38 PM »
well..here is what ive got not much but.....here it goes...

Code: [Select]
;;Wynn Engineering Inc.
;;plog.LSP file CREATED BY SOUK
;;souksavanh nomichith
;;last update 03-05-05

;;text will be printed out in this format
;;job number;job name;sheet size;date;user;b/nb


;;date function from the help of "http://www.afralisp.com/lispa/lisp40a.htm"



(defun today( / d yr mo day)
;define the function and declare all variabled local
(setq d (rtos (getvar "CDATE") 2 6)
     ;get the date and time and convert to text

          yr (substr d 3 2)
 ;extract the year

          mo (substr d 5 2)
 ;extract the month

         day (substr d 7 2)
;extract the day

     );setq

     (strcat mo "/" day "/" yr)
     ;string 'em together
)

(defun c:plog ( / jn jna shts userN thedate bill stringoutput fileopen)
 
(setq jn (getstring "Job number: "))
(setq jna (getstring "Job name: "))
(setq shts (getstring "Sheet size: "))
(setq userN (getvar "loginname"))
(setq thedate (today))
(setq bill (getstring "Billable or Non-billable enter B or NB:"))
(setq stringoutput (strcat jn";"jna";"shts";"thedate";"userN";"bill";"))

(setq file_open (open "c:\\plotterlog.txt" "a"))
(write-line stringoutput file_open)
(close file_open)
(princ)
  );;end defun


no error checking
Quote
if, then, else
i also want it to grab the sheet size that i print out. rather than having to type it in. so what ya think...?

daron

  • Guest
output a .txt file
« Reply #7 on: May 03, 2005, 02:48:32 PM »
Code: [Select]

(setq jn (getstring "Job number: "))  
(setq jna (getstring "Job name: "))
(setq shts (getstring "Sheet size: "))
(setq userN (getvar "loginname"))
(setq thedate (today))
(setq bill (getstring "Billable or Non-billable enter B or NB:"))

My thinking is that if you want to use this to check each plot you want zero(0) user input. Therefore you need to figure out what is being used for each getstring and place it automatically. Job number? Would that be the same as the drawing name? If you use tabs, collect the drawing name and current tab. What is "Job name"? Can there be any variables manipulated to collect it? Sheet size should be able to be collected without UI. As for the B or NB, look into getinit and getkword. This will ensure users will put at least one proper value. Nice beginning though.

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #8 on: May 03, 2005, 02:53:39 PM »
thanks man...i want to be able to have zero user input but im not familiar with the variables that define then...now getinit and getkword are new to me....im gonna go look those up. brb.

btw..is this the wrong area to put this topic?

daron

  • Guest
output a .txt file
« Reply #9 on: May 03, 2005, 03:01:51 PM »
Quote from: dubb
thanks man...i want to be able to have zero user input but im not familiar with the variables that define then...now getinit and getkword are new to me....im gonna go look those up. brb.

btw..is this the wrong area to put this topic?


You're welcome.

<btw...topic?
Where else would you put it? The Teach Me forum is for teaching others what you know and the Show Your Stuff forum is for your Alpha code that you'd like to give out because you're pleased by the outcome of your work. This forum is for beating the dead horse. I'd say it's in the right place.

Does the "Job number" relate to the drawing name, i.e. G32243-01.dwg?
What of "Job name"? What is it, generally?
Billable? Sounds like you want to keep track of what's being printed for charging your customer for sending them print jobs.

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #10 on: May 03, 2005, 03:36:57 PM »
Quote
Does the "Job number" relate to the drawing name, i.e. G32243-01.dwg?
What of "Job name"?


the drawing names are written: 05-505S10.dwg
which means that the drawings is 2005 the project number is 505 and the sheet name is S10 (S-1.0)

Quote
What is it, generally?
Billable? Sounds like you want to keep track of what's being printed for charging your customer for sending them print jobs

the billable area are just like you say. the routine will probably not be entirely zero user input. maybe some comments as well.

i know that there are many programs that do this type of routine that im making. however, they charge per seat and they are usually done in other programming languages.

this one will be included in my custom menu and the routine will be ran directly after the "plot" command. which is still come.

daron

  • Guest
output a .txt file
« Reply #11 on: May 03, 2005, 04:52:28 PM »
I know CAB's batch plot routine, you'll find in Show Your Stuff can be overwhelming for a noob, but you might give it a look to see how you might integrate your own plot utility into this. As far as the job number goes, you can substr, strlen, and a few other utilities to break down and rebuild the info you want from the .dwg name.

What do your users put in place of job name?

I'll ponder the billable part. That may be something like putting a toggle in the dialog box of your own custom plot utility.

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #12 on: May 03, 2005, 05:09:17 PM »
Quote
What do your users put in place of job name?
we put the last name of the client. should there be a list to choose from?

Quote
I know CAB's batch plot routine,....


hehe..his routine seems like it would work..but i tore up my hair trying to get it to work....so then i tried to create it myself.

daron

  • Guest
output a .txt file
« Reply #13 on: May 04, 2005, 08:11:14 AM »
Quote from: dubb
Quote
What do your users put in place of job name?
we put the last name of the client. should there be a list to choose from?

That would be a thought. You could put it in as a pulldown required in order to print with a non-billable field as a default, then you'd be able to remove the billable/non-billable field altogether.
Quote from: dubb

Quote
I know CAB's batch plot routine,....

hehe..his routine seems like it would work..but i tore up my hair trying to get it to work....so then i tried to create it myself.

Take it block by block. Learn what's going on in each defun and how it's happening. I know it's a bit higher level than what you're at, but you should be able to wade through it. Ask questions on it, when you don't understand how something works.

This seems like a very useful project; good for your learning and maybe others' might have a use for it.

dubb

  • Swamp Rat
  • Posts: 1105
output a .txt file
« Reply #14 on: May 04, 2005, 04:08:47 PM »
is there  a way to execute another function after the "Plot" command in autocad?

my best guess....REACTOR?