Isolate DTEXT.......one Small Problem Now

Discussion in 'AutoCAD' started by sashk, Jul 24, 2003.

  1. sashk

    sashk Guest

    Okay, I figured out the whole thing, but I have one problem.
    If the user selects the option to pick his/her own text, they can do it. Then, it will alert them the amount of enities that have been changed to the 00DTEXT layer. But the problem is that is nothing is selected, or all of the text is filtered out because it is mtext, it will error out instead of saying "0 text enities changed" Why is this??

    Here is the routine

    (defun c:isodtext ()
      (command "._undo" "begin")
      (if (not (tblsearch "layer" "00DTEXT"))
        (command "_.layer" "make" "00DTEXT" "c" "yellow" "" "")
        )
      (initget "Whole Select");cannot write "No Point"....space will throw the code off!
      (setq wholeselect (getkword " \nDo You Want to elect Your Own Area To Analyze for DTEXT\nor Have it Select the [W]hole Drawing for You? "))

    (if (= wholeselect "Whole")
          (progn
    (setq DTEXT (sslength (ssget "x" '((0 . "TEXT")))))
            (COMMAND "_.CHANGE" "P" "" "P" "LA" "00DTEXT" "")
    (COMMAND "_.CHANGE" "P" "" "P" "C" "BYLAYER" "")
            (alert (strcat (itoa DTEXT) " Dtext Enities Have Been Placed on the 00DTEXT Layer.\nPlease Change to Mtext Enities "))
    );end progn
        );end if

    (if (= wholeselect "Select")
          (progn
    (setq DTEXT (sslength (ssget '((0 . "text")))));ask user to select area for analysis
            (COMMAND "_.CHANGE" "P" "" "P" "LA" "00DTEXT" "")
    (COMMAND "_.CHANGE" "P" "" "P" "C" "BYLAYER" "")
            (alert (strcat (itoa DTEXT) " Dtext Enities Have Been Placed on the 00DTEXT Layer.\nPlease Change to Mtext Enities "))
    );end progn
        );end if
      (command "._undo" "end")
      (princ)
      )
     
    sashk, Jul 24, 2003
    #1
  2. The function (sslength) returns an error if the argument is nil, which it
    could be if the call to (ssget) finds no matching objects.

    (setq DTEXT (sslength (ssget "x" '((0 . "TEXT"))))) ; this is buggy

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Okay, I figured out the whole thing, but I have one problem.
    | If the user selects the option to pick his/her own text, they can do it.
    Then, it will alert them the amount of enities that have been changed to the
    00DTEXT layer. But the problem is that is nothing is selected, or all of the
    text is filtered out because it is mtext, it will error out instead of
    saying "0 text enities changed" Why is this??
    | Here is the routine
    |
    | (defun c:isodtext ()
    | (command "._undo" "begin")
    | (if (not (tblsearch "layer" "00DTEXT"))
    | (command "_.layer" "make" "00DTEXT" "c" "yellow" "" "")
    | )
    | (initget "Whole Select");cannot write "No Point"....space will throw the
    code off!
    | (setq wholeselect (getkword " \nDo You Want to elect Your Own Area To
    Analyze for DTEXT\nor Have it Select the [W]hole Drawing for You? "))
    |
    | (if (= wholeselect "Whole")
    | (progn
    | (setq DTEXT (sslength (ssget "x" '((0 . "TEXT")))))
    | (COMMAND "_.CHANGE" "P" "" "P" "LA" "00DTEXT" "")
    | (COMMAND "_.CHANGE" "P" "" "P" "C" "BYLAYER" "")
    | (alert (strcat (itoa DTEXT) " Dtext Enities Have Been Placed on
    the 00DTEXT Layer.\nPlease Change to Mtext Enities "))
    | );end progn
    | );end if
    |
    | (if (= wholeselect "Select")
    | (progn
    | (setq DTEXT (sslength (ssget '((0 . "text")))));ask user to select area
    for analysis
    | (COMMAND "_.CHANGE" "P" "" "P" "LA" "00DTEXT" "")
    | (COMMAND "_.CHANGE" "P" "" "P" "C" "BYLAYER" "")
    | (alert (strcat (itoa DTEXT) " Dtext Enities Have Been Placed on
    the 00DTEXT Layer.\nPlease Change to Mtext Enities "))
    | );end progn
    | );end if
    | (command "._undo" "end")
    | (princ)
    | )
    |
     
    R. Robert Bell, Jul 24, 2003
    #2
  3. sashk

    sashk Guest

    Thats what I figured.....how do I fix this??
     
    sashk, Jul 24, 2003
    #3
  4. sashk

    sashk Guest

    Attached is the routine
     
    sashk, Jul 24, 2003
    #4
  5. (if
    (and
    (= wholeselect "Whole")
    (setq ssText (ssget "x" '((0 . "TEXT"))))
    )
    (progn
    (setq DTEXT (sslength ssText))
    (COMMAND "_.CHANGE" ssText "" "P" "LA" "00DTEXT" "C" "BYLAYER" "")
    (alert (strcat (itoa DTEXT) " Dtext Enities Have Been Placed on the
    00DTEXT Layer.\nPlease Change to Mtext Enities "))
    ) ;_ end progn
    ) ;_ end if




    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Thats what I figured.....how do I fix this??
     
    R. Robert Bell, Jul 24, 2003
    #5
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.