Jump to content

Export Coordinates from AutoCAD Help


Kcks

Recommended Posts

Hey guys,

 

I had a question about how to extract/export the coordinates from an AutoCAD drawing.

I'm drawing an airfoil profile in autocad drawing and I want now to know the coordinates of the profile, so I can put in Xfoil and test some properties of the designed airfoil. (The airfoil consist out an Arc and couple of lines)

 

I have already read some older thread but still I couldn't figure it out.

I have made the PO2TXT file, but when using it I get an error:

 

Select objects:

bad argument type: numberp: nil

 

What am I doing wrong?

 

And if I enter this in the command line:

 

(entget (car (entsel)))

 

I get this:

 

Select object: ((-1 . ) (0 . "LWPOLYLINE") (330 .

) (5 . "257") (100 . "AcDbEntity") (67 . 1) (410 .

"Layout1") (8 . "0") (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 .

0.0) (39 . 0.0) (10 65.9154 136.055) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)

(10 65.9154 136.055) (40 . 0.0) (41 . 0.0) (42 . -0.156819) (91 . 0) (10

226.935 112.905) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 157.819 104.82)

(40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 113.846 97.504) (40 . 0.0) (41 .

0.0) (42 . 0.0) (91 . 0) (10 77.0725 88.8182) (40 . 0.0) (41 . 0.0) (42 . 0.0)

(91 . 0) (210 0.0 0.0 1.0))

 

And I really don't have an idea what to do now, can someone help me.?

Also is there another method to extract coordinates form an autocad drawing without use LISP?

 

more information:

I'm using AutoCAD 2011 (Trail version)

and I can be seen as a Newbie.

 

Regards,

 

Kcks

Link to comment
Share on other sites

Here is a lisp would get your coordinates to a file named (D:coordinates.txt) on drive D:...

 

Hope this what you look for ...

(defun c:THpts (/ fNme pt pts coords)
 ; THARWAT Oct. 31.2010
 (setq fNme (open "D:/coordinates.txt" "w"))
   (while
     (setq pt (getpoint "\n Specify point :"))
     (setq pts (trans pt 1 0))
   (setq coords
   (write-line
          (strcat (rtos (car pts) 2)
		  ","
	          (rtos (cadr pts) 2)
	          ","
	     (rtos (caddr pts) 2))
	  fNme)
  )
     )
   (close fNme)
 (princ)
 )

 

Tharwat

Link to comment
Share on other sites

Thanks for the quick reply guys.

@ReMark: I have downloaded both file but the first files only extraxt some point of the object (like beginning and end). The second file gave me 5 coordinates of points and didn't see the arc as an object, thus I couldn't select it.

 

@Tharwat: It did help me much.

 

I realized that I have a line (beginning and end point) and what I wanted was the coordinates of the line including everything between the beginning and end point.

So I need to make points on the line and then use the programs, right. Or is there some code which can give the coordinates of a line with segment of 1 (for example shop the line into 100 point and the give each coordinate)

 

Regards,

Kcks

Link to comment
Share on other sites

Check this out ......

 

(defun c:THcoords (/ fNme ss e x  y )
 ; THARWAT Nov. 03.2010
 (setvar 'pdmode 3)
 (setq fNme (open "D:/coordinates.txt" "w"))
   (while
     (setq ss (car (entsel "\n Select Line :")))
     (entmakex (list (cons 0 "POINT") (cons 10  (cdr (assoc 10 (setq e (entget ss)))))))
     (entmakex (list (cons 0 "POINT") (cons 10 (cdr (assoc 11 e)))))
     (setq x (cdr (assoc 10 e)))
     (write-line
          (strcat (rtos (car x) 2)
		  ","
	          (rtos (cadr x) 2)
	          ","
	     (rtos (caddr x) 2))
	  fNme)
    (setq y (cdr (assoc 11 e)))
   (write-line
          (strcat (rtos (car y) 2)
		  ","
	          (rtos (cadr y) 2)
	          ","
	     (rtos (caddr y) 2))
	  fNme) 
     )
   (close fNme)
 (princ)
 )

 

Tharwat

Link to comment
Share on other sites

@Tharwat: It did help me much.

 

I realized that I have a line (beginning and end point) and what I wanted was the coordinates of the line including everything between the beginning and end point.

 

That was your request and I made it for you accordingly.

 

Tharwat

Link to comment
Share on other sites

You could also export the coordinates without using Lisp, but using the commands within AutoCAD.

 

First make a simple block (a cross or something similar). Then use Measure, using your block, at intervals of 100. Then use Attribute extraction which gives the Insertion coordinates of all the blocks. :D

Link to comment
Share on other sites

Sorry my last reply was to ReMark.

Your second code did exactlly what I trying to do by hand :P . Thanks for it

Kcks

 

Don't feel shy, if you need any modification , you're more than welcome. And I would modify them for you buddy. :)

 

Just be stright to the point to let me give you the right thing.

Best Regards,

 

Tharwat

Link to comment
Share on other sites

Hey guys I wanted to thank you all. Tharwat your second code worked perfectly, eldon the method you decribes also worked perfect. And the tips of ReMark did the extracting of the coordinates to a .txt which I can use for xfoil-testing.

Thanks for the quick reply all.

 

Greeting Kcks.

Link to comment
Share on other sites

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