INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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.

Jobs

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)))
    (princ)       
    ;now out to file
    (princ "\n\"(" out)
    (princ (LIST(dxf 0 EDDY)) out)
    (princ)
    (setq Sneaky (+ 1 Sneaky))
    (SETQ typ (dxf 0 EDDY))
        (cond
           ((= typ "LWPOLYLINE") (exportMpoints EDDY))
           (t (exportPoints EDDY))
       )
  
  );end while
(close out)
  (print "Where did that txt file go?...")
  (print (findfile "MyEntities.txt"))
  (princ)
)
;
(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)
  (princ)
  )
;
(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)
  (princ)
)
;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)
  ;entmake
  ;entmod
  );
(close in)
  (princ)
)

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

My Archive


Resources


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