Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

AutoLisp Tricks

To illustrate the entity list of Acad Drawing Objects by tigrek
Posted: 18 Aug 01

(defun C:xpoint()
;inspired by Todd Wessendorf of Alexandria, Virginia

;This code exports the coordinates of  entities.
;Line, LwPolyLine, arc, ellipse, circle etc.
;to a txt file.
;For tutorial purpose, the full entity list is dumped on the command line for you to become familiar with - where the coordianets are, the entity type, layer, color etc.

;open a text file to append  exports -you can write full path
  (setq out (open "MyEntities.txt" "a"))
(setq Suzy (ssget))
  (setq Suzilen (sslength Suzy))
  (setq Sneaky 0)
  (while (< Sneaky Suzilen)
    (setq EDNA (ssname Suzy Sneaky))
    (setq EDDY (entget EDNA))
    (print (+ 1 Sneaky))(Princ "\nEDDY ... ")
    (print EDDY)
    (princ "\n");new line
    (princ (LIST(dxf 0 EDDY)))
    ;now out to file
    (princ "\n\"(" out)
    (princ (LIST(dxf 0 EDDY)) out)
    (setq Sneaky (+ 1 Sneaky))
    (SETQ typ (dxf 0 EDDY))
           ((= typ "LWPOLYLINE") (exportMpoints EDDY))
           (t (exportPoints EDDY))
  );end while
(close out)
  (print "Where did that txt file go?...")
  (print (findfile "MyEntities.txt"))
(defun dxf (n ed) (cdr (assoc n ed)))
(defun exportpoints(EDDY)

  ;to see on command line
  (if (dxf 10 EDDY)(princ (dxf 10 EDDY)))
  (if (dxf 11 EDDY)(princ (dxf 11 EDDY)))
  ;now same thing to append to file
  (if (dxf 10 EDDY)(princ (dxf 10 EDDY) out))
  (if (dxf 11 EDDY)(princ (dxf 11 EDDY) out))
  (princ ")\"" out)
(defun exportMpoints(ShortEDDY)
(while (setq ShortEDDY (member (assoc 10 ShortEDDY) ShortEDDY))
    (princ (dxf 10 ShortEDDY))
      ;now append to file
      (princ (dxf 10 ShortEDDY) out)
    (setq ShortEddy (cdr ShortEddy))
  (princ ")\"" out)
;Homework - see AutoLisp helpfile (type VLIDE on Acad Command line) for
;read, read-line, entmake, entmod
;to write the reverse function that makes entities from coords in txt file.
;debug and correct the following. String lines are to be read as or made lists
;to use in entmake
(defun C:imPoint()
  (setq in (open "MyEntities.txt" "r"))
  (while (setq myEnt (read-line in))
    (princ "\n")
    (princ myEnt)
(close in)

Back to Autodesk: AutoCAD FAQ Index
Back to Autodesk: AutoCAD Forum

My Archive


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close