Exporting Text with AutoLISP

Discussion in 'AutoCAD' started by Cadman (remove x), Jul 22, 2004.

  1. This Lisp will do selection in window or all for R14 and R2000:

    (setq v:editor "c:\\programme\\utils\\editpad.exe")


    (defun c:tex ( / a b c d e f g h i l r)
    (graphscr)
    (setq l (getpoint "1. Fensterpunkt :"))

    (if l
    (setq
    r (getcorner l "2. Fensterpunkt :")
    a (ssget "_W" l r ) ; Texte im Fenster suchen keine Filterliste moeglich
    a (onlyent a "TEXT")
    )
    (setq
    a (ssget "X" (list (cons 0 "TEXT"))) ; alle Texte suchen
    )
    ) ; end if


    (if (< 0 (sslength a))
    (progn
    ;(prall (list "\n" (sslength a) " Elemente gefunden.\n" ))

    (setq
    g 0
    d (open "scr.scr" "w")
    )

    ; Text an Editor übergeben

    (while (< g (sslength a) )
    (setq
    h (ssname a g)
    e (entget h)
    b (feld 0 e)
    c (feld 1 e)
    )
    (if (= "TEXT" b)
    (progn
    (princ (strcat c "\n") d)
    (setq g (1+ g))
    )
    ; aus Auswahlsatz entfernen
    (setq a (ssdel h a))
    )
    ) ; ende while
    (close d)(setq d nil)

    (setq b " scr.scr")

    (startapp v:editor b)


    ; Text von Editor übernehmen wenn dieser fertig ist
    ; bei Windows wegen Multitasking jetzt Programm anhalten

    (getstring "\nEditor fertig ? ")

    (setq
    f (sslength a) g 0
    d (open "scr.scr" "r")
    )
    (while (< g f)
    (setq
    e (entget (ssname a g))
    c (read-line d) ; Zeile lesen
    )
    (if (/= c (feld 1 e))
    (progn
    (setq
    e (append (list (assoc -1 e)) (list (cons 1 c)))
    )
    (setq i (entmod e))
    (if (not i)
    (getstring "\nElement nicht nachgefuehrt!")
    (princ "Erfolgreich nachgefuehrt\n")
    )
    ) ; Ende progn wenn ungleich
    (princ "Element gleich\n")
    ) ; Ende if
    (setq g (1+ g))
    ) ; ende while
    (close d)(setq d nil)
    (redraw)(grtext)
    ) ; ende progn
    (princ "\nKeine Texte gewaehlt.\n")
    ) ; ende if
    (princ)
    )


    ( defun prall ( a / b )
    ( foreach b a (princ b ))
    (princ )
    )


    (defun Onlyent ( a e / b f h i)
    (setq i 0)
    (while (< i (sslength a) )
    (setq
    h (ssname a i)
    f (entget h)
    b (feld 0 f)
    )
    (if (= e b)
    (setq i (1+ i))
    ; aus Auswahlsatz entfernen
    (setq a (ssdel h a))
    )
    ) ; ende while

    a
    )


    (defun feld ( a b)
    (cdr(assoc a b))
    )


    (defun startapp ( a b / c)
    (setq c (strcat a " " b))
    (command "Shell" c)

    )
     
    Cadman (remove x), Jul 22, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.