Author Topic: Pick Text HIT or MISS  (Read 2317 times)

0 Members and 1 Guest are viewing this topic.

mhcadman

  • Guest
Pick Text HIT or MISS
« on: June 12, 2008, 02:00:08 PM »
hello all..... :-)

please - i need a lsp to do the following - please

    ;;;;;;;;attempt to pick some text

    if the pick misses the text then try again
        else
            perform the task contained in this section
                     then start this lsp over
    end if
    end lsp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
please help

sincerely,
mike
 :-)

Chuck Gabriel

  • Guest
Re: Pick Text HIT or MISS
« Reply #1 on: June 12, 2008, 02:07:03 PM »

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Pick Text HIT or MISS
« Reply #2 on: June 16, 2008, 07:55:10 PM »
Those are all really complicated ways, here is how I handle it:
Code: [Select]
(setq ob nil);Set the variable to nil for use later
(setq ob (entsel "\nPlease select text: "));Ask for input
(while (= ob nil);If input is not provided, keep asking until it is provided or the command is canceled.
    (setq ob (entsel "\nYou need to select text or cancel the command.\nPlease select text: ")); Asks for input
); End of loop

If I need a point:
Code: [Select]
(setq pt nil)
(setq pt (entsel "\nPlease select text: "))
(while (= pt nil)
    (setq pt (getpoint "\nYou need to select text or cancel the command.\nPlease select text: "))
)

If I need to get an object based on the point:
Code: [Select]
(setq pt nil)
(setq ob nil)
(setq pt (entsel "\nPlease select text: "))
(while (= ob nil)
(progn
   (while (= pt nil)
       (setq pt (getpoint "\nYou need to select text or cancel the command.\nPlease select text: "))
    )
    (setq ob (nentselp "" pt));This allows you to select something without the user actually picking on it.
    (if (= ob nil);If there is no object, require the user to keep picking until the get something.
       (setq pt nil)
    )
)
)

Hopefully that is enough to get you started.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pick Text HIT or MISS
« Reply #3 on: June 16, 2008, 09:40:06 PM »
Those are all really complicated ways, here is how I handle it:
That's in the eye of the beholder.  :evil:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Pick Text HIT or MISS
« Reply #4 on: June 17, 2008, 01:52:16 AM »
Hi,

Code: [Select]
(while
  (not
    (and
      (setq ent (car (entsel "\nPick a text: ")))
      (= (cdr (assoc 0 (entget ent))) "TEXT")
    )
  )
   (princ "Missed text, try again.")
)
Speaking English as a French Frog