Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

To illustrate the entity list of Acad Drawing Objects

AutoLisp Tricks

To illustrate the entity list of Acad Drawing Objects

by  tigrek  Posted    (Edited  )
(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)
)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search