Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to export any data from autocad to any database application

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
abdulhasiin
1955 Views, 9 Replies

how to export any data from autocad to any database application

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. 

shearforce.png

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? 

9 REPLIES 9
Message 2 of 10
hmsilva
in reply to: abdulhasiin

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

EESignature

Message 3 of 10
abdulhasiin
in reply to: hmsilva

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 

Message 4 of 10
hmsilva
in reply to: 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

EESignature

Message 5 of 10
abdulhasiin
in reply to: hmsilva

Thanks a ton for this Henrique. Tested..working perfectly. thanks
Message 6 of 10
hmsilva
in reply to: abdulhasiin

You're welcome, Abdulhasiin
glad I could help

Henrique

EESignature

Message 7 of 10
abdulhasiin
in reply to: hmsilva

A great help indeed 🙂
Message 8 of 10
abdulhasiin
in reply to: abdulhasiin

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. 

Message 9 of 10
hmsilva
in reply to: abdulhasiin

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

EESignature

Message 10 of 10
abdulhasiin
in reply to: hmsilva

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost