Results 1 to 4 of 4

Thread: Select all objects in current workspace

  1. #1
    Member
    Join Date
    2001-03
    Location
    ROMANIA
    Posts
    35
    Login to Give a bone
    0

    Default Select all objects in current workspace

    Using VLisp, I want to make a selection set that contains all the objects in the current workspace.
    I do not know how to set one of the vlax-safearray-fill function arguments to exclude from the selection the objects on layers Freeze, Off and Lock.

    Code:
    (setq ACDC (vla-get-activedocument (vlax-get-acad-object)))
    (vlax-for
     Obj
     (vla-get-layers ACDC)
     (if (or ;;Filter layers locked, frozen or off
       (eq (vla-get-freeze  Obj) :vlax-true)
       (eq (vla-get-lock    Obj) :vlax-true)
       (eq (vla-get-layeron Obj) :vlax-false)
      )
    ;;   (setq L_FILTER (append (list (vla-get-name Obj)) L_FILTER)) ;;Layer list
      (setq L_FILTER (append (list (list (vla-get-name Obj))) L_FILTER)) ;;Layer list of lists
     )
    )
    (setq SS_ALLO (vla-add (vla-get-selectionsets ACDC) (itoa (getvar "MILLISECS")))
      F_CODE (vlax-make-safearray vlax-vbinteger (quote (0 . 1)))
      F_VALE (vlax-make-safearray vlax-vbvariant (cons 0 (1- (length L_FITER))))
    )
    (vlax-safearray-fill F_CODE (quote (8 410)))
    (vlax-safearray-fill F_VALE  (list what_to_write_here? (getvar "CTAB")))
    (vla-select SS_ALLO acSelectionSetAll nil nil F_CODE F_VALE)

    Thank you.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Select all objects in current workspace

    Hi,
    Simply this.
    Code:
    (setq f "")
    (while (setq l (tblnext "LAYER" (not l)))
      (or (/= (cdr (assoc 70 l)) 0)
          (minusp (cdr (assoc 62 l)))
          (wcmatch (setq n (cdr (assoc 2 l))) "*|*")
          (setq f (strcat n "," f))
          )
      )
    (setq ss (ssget "_X" (list (cons 8 (if (= f "") "*" f)) (cons 410 (getvar 'CTAB)))))

  3. #3
    Member
    Join Date
    2001-03
    Location
    ROMANIA
    Posts
    35
    Login to Give a bone
    0

    Default Re: Select all objects in current workspace

    Quote Originally Posted by Tharwat View Post
    Hi,
    Simply this.
    Code:
    (setq f "")
    (while (setq l (tblnext "LAYER" (not l)))
      (or (/= (cdr (assoc 70 l)) 0)
          (minusp (cdr (assoc 62 l)))
          (wcmatch (setq n (cdr (assoc 2 l))) "*|*")
          (setq f (strcat n "," f))
          )
      )
    (setq ss (ssget "_X" (list (cons 8 (if (= f "") "*" f)) (cons 410 (getvar 'CTAB)))))
    Thank you Tharwat for your snippet.
    Unfortunately, the solution is not quite right because the name of the layer or layout could conflicts with one of the special characters used by the ssget function. See Lee Mac's explanation here.
    Run your snippet two times: without and with, let's say # character into the name of an active layer. In both cases, count the number of selected entities.
    Therefore, in order to avoid using the ssget function and an additional condition inside the code, I tried the solution with VLisp; these are drawings with thousands of entities and dozens of layers and the speed of the code is important.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Select all objects in current workspace

    Of course there's an obvious way of avoiding issues from using characters such as #, @, ., *, ?, etc when naming layers, files, etc. Just don't do it!

Similar Threads

  1. 2016: Unable to select objects under other objects ona a locked layer
    By mattko in forum AutoCAD General
    Replies: 16
    Last Post: 2016-08-02, 03:18 PM
  2. Ability to snap to all objects in a 3D view, not just objects on the current reference plane
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2010-03-12, 06:09 AM
  3. Replies: 11
    Last Post: 2006-11-06, 06:43 PM
  4. Replies: 9
    Last Post: 2006-10-23, 02:30 PM
  5. Replies: 3
    Last Post: 2006-09-16, 04:01 PM

Posting Permissions

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