Outputting entity information

Howdy, I'd like to know if it is possible to output the X, Y, and Z co-ordinates of the various entities in a DWG file? If I had 4 lines that made a square
that was 4" long in the X and 2 " in the Y, with the bottom left corner at X0 and Y0.
I've heard this can be done in Lisp, or something similar to it anyways.
If anyone could point me in the right direction I would greatly appreciate it. thanks in advance. John
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
It depends on what you want to do with the data. You can get the coordinates of any point with the ID command; and you can LIST a line to see its endpoints. If you want to extract, for example the endpoints of a line to be used in some other operation, then you will probably have to resort to LISP. Give us a few more details about what you want, and someone will probably point you in the right direction. ___

of
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
John W. Higgins wrote:

Warning: No error trapping included, here, just the basics, and not necessarily functioning code.
(defun C:LINEOUT ( / enam pt1 pt2) (setq enam (car (entsel "\nSelect line: ")) pt1 (cdr (assoc 10 (entget enam))) pt2 (cdr (assoc 11 (entget enam))) crd1 (strcat (rtos (car pt1)) "," (rtos (cadr pt1)) "," (rtos (caddr pt1)) );strcat crd2 (strcat (rtos (car pt2)) "," (rtos (cadr pt2)) "," (rtos (caddr pt2)) "," );strcat ofil (open "c:\MyLineFile.txt" "a") );setq (write-line crd1 ofil) (write-line crd2 ofil) (close ofil) (princ) );defun
.........I've got myself curious, now.......I'll test this and repost.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
TomD wrote:

One glitch..........change the above line to:
ofil (open "c:\\MyLineFile.txt" "a")
...two backslashes are required.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
What I am doing is working for a company that doesn't want to spend the money to buy a Cad/Cam package they can use to program their CNC machines. We use our CNC Milling machine to do simple stuff such as drill holes, mill a quick slot, etc. The machine has a very good conversational programming interface that makes it easy to do the simple stuff like this. Every now and then they want to do something that is a little more complex, or the conversational programming cannot simplify for us. An example of this is to engrave part numbers or cut various logo's into a part. When the geometry has straight lines and the like it is easy enough to make something close to waht they want. When there are arcs and lines it becomes more difficult to sit down and figure out in a timely fashion. If we know each of the points in the object it is easy to program of course. When the specifications are vauge, such as 'Engrave or stamp items 2, 4 and 5'. it becomes more difficult. We have to sit down and figure out where each of the points are and then program it in our machine. I have in the past drawn whatever it is in Autocad, then found the lines end points as well as any arc centers and noted them down. This works pretty good. It is cheap and fairly easy to do. The problem is when we have to engrave our numbers. There are so darn many points on a 12 digit number that its getting pretty tiresome noting down all those points and taking them to the programmer, or keying them in myself.
So, what I'd like to do is be able to output the X,Y co-ordinates of the various entities. Then I can just take the sheet down and input them. I have recently became aquainted with the LIST command and that works pretty darn good. I wish I'd dug through the book before I asked. I will try the LISP routine though and get back here.
I do thank you for the help.
John
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
John W. Higgins wrote: <SNIPPED>

If this is something you do regularly (which it sounds like is true), lisp is definitely worth looking into. The code I posted is very basic, only for lines with no error checking, etc., but in your case, should be a good start.
I'd think you would want to write out polyline info, which gets a little more involved, but still isn't terribly complicated.
Good luck, and re-post any specific questions regarding doing this with lisp. A number of the regulars here are quite good with it. I'm ok, but I'm no programmer. ;)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Thanks TomD for the lineout lisp routine. That worked like a charm. I made a couple of changes so that it would include X,Y and Z before each of the coordinate values it output, but other than that it was perfect. I don't have to do this real regularly, but since it is getting easier, I may volunteer for it a little more. Thanks for taking the time. John Higgins
If this is something you do regularly (which it sounds like is true), lisp is definitely worth looking into. The code I posted is very basic, only for lines with no error checking, etc., but in your case, should be a good start.
I'd think you would want to write out polyline info, which gets a little more involved, but still isn't terribly complicated.
Good luck, and re-post any specific questions regarding doing this with lisp. A number of the regulars here are quite good with it. I'm ok, but I'm no programmer. ;)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.