TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hangman on April 22, 2006, 08:29:12 PM

Title: Select a text w/out pick'n it.
Post by: Hangman on April 22, 2006, 08:29:12 PM
Hey all, could you enlighten me with an idea of how to select a text previously created.

Here's the issue.
Code: [Select]
  (setq pt1 (getpoint "\nSelect Corner or Edge of Entity: "))
  (setq ang1 (getangle pt1 "\nSelect angle or Return for 45: "))
  (if (= ang1 nil)
      (setq ang1 (/ pi 4))
  );end if
  (setq ang2 (cvunit ang1 "radian" "degree"))
  (command "dtext" pt1 ang2 pause)

So, after the dtext has been written.  Be it two, three, or four lines or more, is it possible to assign each line of text to a variable without physically selecting each line ?  And if so, how can this be done ?

Thank you.
Title: Re: Select a text w/out pick'n it.
Post by: Kerry on April 22, 2006, 09:17:28 PM
You could try something like this ..
Code: [Select]
(DEFUN test (/ dtext-ss dtext-list index ent)
   (kb:mark)
   (VL-CMDF "dtext" '(0 0 0) 35 0.0 pause)
   (SETQ dtext-ss (kb:catch)
         dtext-list '()
         index -1
   )
   (SETQ dtext-list
           (REVERSE
              (WHILE
                 (SETQ ent (SSNAME dtext-ss (SETQ index (1+ index))))
                   (SETQ
                      dtext-list (CONS (CDR (ASSOC 1 (ENTGET ent)))
                                       dtext-list
                                 )
                   )
              )
           )
   )
   dtext-list
)

Using these library routines ..
Code: [Select]
;; // MarkCatch.LSP
;; based on New Rider Articles { I think }

;;;-----------------------------------------------------------------------------------
;;;-----------------------------------------------------------------------------------
;;;  KB:mark
;;; Mark data base to allow KB:catch.
;;;
(defun kb:mark ( / val)
  (setq val (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (if (setq *KG:mark (entlast))
    nil
    (progn (entmake '((0 . "POINT") (10 0.0 0.0 0.0)))
           (setq *KG:mark (entlast))
           (entdel *KG:mark)
    )
  )
  (setvar "cmdecho" val)
  (princ)
)
;;;-----------------------------------------------------------------------------------
;;;-----------------------------------------------------------------------------------
;;;  KB:catch
;;; returns selection set of entities since last KB:mark.
;;;
(defun kb:catch (/ ss tmp)
  (if *KG:mark
    (progn (setq ss (ssadd))
           (while (setq *KG:mark (entnext *KG:mark)) (ssadd *KG:mark ss))
           (command "._select" ss "")
           (setq tmp ss)
    )
    (alert "*KG:mark not set. \n Run KB:mark before KB:catch.")
  )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
Title: Re: Select a text w/out pick'n it.
Post by: CAB on April 22, 2006, 09:31:56 PM
See the subroutines in this lisp.
http://www.theswamp.org/index.php?topic=7794.msg99078#msg99078