Results 1 to 4 of 4

Thread: Object selection with a keyword option

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Object selection with a keyword option

    Hi All

    Is there a that I can get a user the choice to select object or to enter a keyword as an option? My plan is to prompt the user to "Select objects individually or by [Layer]:". Any objects chosen are added to the selection set or alternatively, they can type"L" and have a subroutine build a selection set by selecting an object on a specific layer. Any help is greatly appreciated. Thanks.

    Manuel

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Object selection with a keyword option

    Code:
    (defun c:FOO  (/ *error* _Nomutt)
      (vl-load-com)
    
      (defun *error*  (msg)
        (and oldNomutt (setvar 'nomutt oldNomutt))
        (if acDoc (vla-endundomark acDoc))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
        (princ))
    
      (defun _Nomutt  (on) (setvar 'nomutt (if on 1 0)))
    
      ((lambda (acDoc oldNomutt / ss layer)
         (vla-startundomark acDoc)
         (if
           (and
             (princ "\nSelect objects, or <Enter> for layer: ")
             (_Nomutt T)
             (or (setq ss (ssget "_:L"))
                 (and
                   (_Nomutt nil)
                   (/= "" (setq layer (getstring T "\nEnter layer name(s): "))))))
    
            (progn
              ;; <- Do something with the ss, or layer string here,
              ;; for now, prompt user what they chose:
              (prompt (strcat "\n** You chose to "
                              (if ss
                                "\"select objects\""
                                "\"enter layer name(s)\"")
                              " ** "))
              (*error* nil))
            ;; If no valid choice is made, report:
            (*error* "You didn't enter a valid option")))
        (vla-get-activedocument (vlax-get-acad-object))
        (getvar 'nomutt)))
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    257
    Login to Give a bone
    0

    Default Re: Object selection with a keyword option

    Renderman
    Thanks for the code. I am still working on the routine but what I have thus far is working exactly as needed. Take care.
    Manuel

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Object selection with a keyword option

    Quote Originally Posted by cadconcepts View Post
    Renderman
    Thanks for the code. I am still working on the routine but what I have thus far is working exactly as needed. Take care.
    Manuel
    You're welcome; Happy to help
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Add to selection without holding ctrl option
    By Wish List System in forum Revit MEP - Wish List
    Replies: 1
    Last Post: 2012-07-04, 12:35 AM
  2. Replies: 11
    Last Post: 2010-10-25, 02:51 PM
  3. Overkill ==> "Invalid option keyword."
    By A Myth in forum AutoCAD General
    Replies: 8
    Last Post: 2007-05-03, 11:11 AM
  4. A third selection option...
    By Danny Polkinhorn in forum Revit - API
    Replies: 1
    Last Post: 2006-12-06, 12:23 AM
  5. Another Selection Option
    By scott.wilcox in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2004-10-27, 02:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •