[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Part1 - Part2 - Single Page

Top Document: comp.cad.autocad AutoLISP FAQ (part 2/2) - samples, code
Previous Document: [21] Sample Lisp Programs:
Next Document: [22] Block Attributes


[21.8] How to write XYZ data of selected objects to a file?


  ;;; CDF - comma delimited string
  (defun CDF-POINT (pt)
    (strcat (car pt) ", " (cadr pt) ", " (caddr pt)))
  ;;; SDF - space delimited, may easier be read back in to AutoCAD
  (defun SDF-POINT (pt)
    (strcat (car pt) " " (cadr pt) " " (caddr pt)))
  ;;; convert this SDF format back to a point with
  (defun STR->POINT (s)
    (eval (read (strcat "(" s ")"))))

  ;;; Write a XYZ file of all selected objects (SDF see below)
  (defun C:XYZ (/ ss fname f)
    (if (and (setq ss (ssget))
          (setq fname (getfiled "Write XYZ to file"
                  (strcat (getvar "DWGNAME") ".XYZ") "XYZ" 7))
          (setq f (open fname "w")))
      (foreach ele (sslist ss)          ; -> [20.4]
        (foreach pt (getpts ele)        ; -> [23.1]
          (write-line (cdf-point pt) f))))
    (if f (close f)))

  ;;; => <fname>.xyz
  ;;; 0.45, 12.3, -34.0

  For a ASC file (SDF-format) simply change all XYZ to ASC
  and cdf-point to sdf-point above.

  For the other way 'round, creating PLINES from a ascii x,y file
  best convert the file to a script like:
  PLINE
  300.2,10
  350.4,10.4



Top Document: comp.cad.autocad AutoLISP FAQ (part 2/2) - samples, code
Previous Document: [21] Sample Lisp Programs:
Next Document: [22] Block Attributes

Part1 - Part2 - Single Page


[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
rurban@xarch.tu-graz.ac.at (Reini Urban)

Last Update July 24 2008 @ 00:12 AM

© 2008 FAQS.ORG. All rights reserved.