I would like to save the data generated by LISP program at command prompt area to any data base app or any simillar app from where I can retrieve the stored data again in autocad for further usage.
For example, A LISP program generate the result as shown in above Fig. I would like to save the data of step 5, "Shear force in tonnage is : 50.868" to any database application or any simillar one from where I can retrieve the stores data for further usage. Is there any one who can help me out in this?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by hmsilva. Go to Solution.
abdulhasiin,
if you could show the code, would be better, without the code will be
a shot in the dark, perhaps something like...
(defun c:test (/ line n ofile) (c:shearforce) (princ "\n") (setq line (getvar "lastprompt") n (+ (vl-string-position (ascii ":") line) 3) line (substr line n) ) (setq ofile (open (strcat (getvar "dwgprefix") (vl-string-right-trim ".dwg" (getvar "dwgname")) "_.csv") "A")) (write-line line ofile) (close ofile) (princ) );; test
will create a ".csv" file, in the directory of the current dwg, with the it's name plus a "_"
try it, is minimally tested...
hope that helps
Henrique
Thanks a lot Henrique..
though its working still I'm showing you the program,
(defun c:shearforce()
(setq no1 (getint "enter the total length of component: "))
(setq no2 (getint "enter the thickness of stock: "))
(setq no3 (getreal "enter the shear strength: "))
(setq shearforce (/ (* 1.2 no1 no2 no3) 1000))
(princ "shear force in tonnage is: ")(princ shearforce)(princ)
(princ " ; Please Enter the command 'diethick' : ")(princ)
)
Thanks a lot.
Abdulhasiin
You're welcome, Abdulhasiin
using your code...
(defun c:shearforce1 (/ no1 no2 no3 ofile) (setq no1 (getint "\nenter the total length of component: ") no2 (getint "\nenter the thickness of stock: ") no3 (getreal "\nenter the shear strength: ") shearforce (/ (* 1.2 no1 no2 no3) 1000) ofile (open (strcat (getvar "dwgprefix") (vl-string-right-trim ".dwg" (getvar "dwgname")) "_.csv")"A")) (write-line (rtos shearforce 2 4) ofile) (close ofile) (prompt (strcat "\shear force in tonnage is: " (rtos shearforce 2 4))) (prompt "\n ; Please Enter the command 'diethick' : ") (princ) )
hope that helps
Henrique
Henrique, Can you explain me this program a little. Same function i need to be used in some other LISP programs I tried using your code. But I'm stuck.
(write-line (rtos bdieblock 2 4) ofile)
What does that 2 and 4 mean?
And this one,
ofile (open (strcat (getvar "dwgprefix")
I'm completely blind here. I Hope you won't mind a little more explaination as you've already done a lot for me.
abdulhasiin,
ofile (open (strcat (getvar "dwgprefix")
it was inside a "setq" function, and it was like this
(setq ofile (open (strcat (getvar "dwgprefix") (vl-string-right-trim ".dwg" (getvar "dwgname")) "_.csv")"A"))
ofile - the variable where you saved the .csv file path
open - to open the file and
"A" - to apend
strcat - returns a string that is the concatenation of multiple strings,
inside the "strcat" function
(getvar "dwgprefix") - to get the current dwg prefix
(vl-string-right-trim ".dwg" (getvar "dwgname")) to trim the ".dwg" from the current dwg name that we obtained with the (getvar "dwgname")
and the "_.csv" to add a underscore to the current dwg name and save the new text file as a ".csv" file type.
(write-line (rtos bdieblock 2 4) ofile) it was not mine...
(write-line (rtos shearforce 2 4) ofile)it was mine
the variable "shearforce" contains a real number, with
rtos - converts a number into a string, and the
(rtos number [mode [precision]])
2 - specifying the linear units mode (in this case 2 is decimal)
4 - is the precision, four decimal places...
You can find documentation on Autolisp and VLISP functions in the help, in the Costumization Guide, and through the VLISP editor that comes with Autocad, the Vlide, you can test the functions and the syntax. At the command prompt type Vlide or VLISP, to start the vlide.
hope that helps
Henrique
Hi Henrique
First of all thanks a lot for your efforts for this problem. I'm done with this project. I started a new one and I need a little help over there. Please Look at this http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Automated-drawing-using-input-data-LI...
Thanks in Advance 🙂
Regards:
Haseeb