ssget off screen selection

DonatasAzaravicius
Advocate
Advocate

ssget off screen selection

DonatasAzaravicius
Advocate
Advocate

Hi,

I am trying to select entities of specified type at specified area to get selected. I use

(ssget "_C" pt1 pt2 filer)

it works only if entities are visible on screen. If entity is not visible on screen (because it is outside visible area on screen) it will not be selected.

_X selects all entities in database, but don't take points.

 

Details:

I have drawing with many blocks in big area and I need to take only one block at some coordinate (if block exist here). So I made function for this:

; Finds blocks of name blockName in specifiend coordinates and returns they handls.
; coordinates - [list] List of coordinates. ( (x0 y0) (x1 y1) ... (xn yn) ) 
; P.S. can have zn, but it will not be used.
; blockName   - [str]  Name of block to find.
; Returns       [list] List of block handls. (handl0 handl1 ... handln)
(defun DA:GetBlocksHandl (coordinates blockName / point handl listOfHandls filter ss)
    (setq 
        listOfHandls (list)
        filter (list '(0 . "INSERT") '(410 . "Model") (cons 2 blockName))
    )
    (foreach point coordinates
        (if (setq ss (ssget "_C" (list (- (car point) 0.1) (- (cadr point) 0.1)) (list (+ (car point) 0.1) (+ (cadr point) 0.1)) filter))
            (setq listOfHandls (cons (cdr (assoc 5 (entget (ssname ss 0)))) listOfHandls))
        )
    )
    (reverse listOfHandls)
)

but it does not select blocks if they are not in visible area on screen. Is here other mods for ssget to make it work or is here different function to select one block of specified name at specified point (if it exist here)?

0 Likes
Reply
Accepted solutions (1)
727 Views
4 Replies
Replies (4)

Sea-Haven
Mentor
Mentor

You may need a zoom E or a zoom C so can see objects.

 

This is like 800 blocks and finds them individually using a CP crossing polygon.

An example a row of text.

(setq ss (ssget "wP" (list pt1 pt2 pt3 pt4 pt1 ) (list (cons 0 "*text"))))

 

SeaHaven_0-1647777716641.png

 

 

 

0 Likes

DonatasAzaravicius
Advocate
Advocate
Accepted solution

Thanks.

WP did not worked for me, because I want to select only one block I make small area around given coordinate, so block is not in area, but just cross it. But this given me idea.

I am reading autolisp reference for ssget function and they example use only 4 points, your use 5 points. So, I changed selection method to CP and added 5 points and it worked. It did not worked with just 4 points as in reference example.

; Finds blocks of name blockName in specifiend coordinates and returns they handls.
; coordinates - [list] List of coordinates. ( (x0 y0) (x1 y1) ... (xn yn) ) P.S. can have zn, but it will not be used.
; blockName   - [str]  Name of block to find.
; Returns       [list] List of block handls. (handl0 handl1 ... handln)
(defun DA:GetBlocksHandl (coordinates blockName / point handl listOfHandls filter ss ptList)
    (setq 
        listOfHandls (list)
        filter (list '(0 . "INSERT") '(410 . "Model") (cons 2 blockName))
    )
    (foreach point coordinates
        (setq ptList (list
                (list (- (car point) 0.1) (- (cadr point) 0.1))
                (list (- (car point) 0.1) (+ (cadr point) 0.1))
                (list (+ (car point) 0.1) (+ (cadr point) 0.1))
                (list (+ (car point) 0.1) (- (cadr point) 0.1))
                (list (- (car point) 0.1) (- (cadr point) 0.1))
            )
        )
        (if (setq ss (ssget "_CP" ptList filter))
            (setq listOfHandls (cons (cdr (assoc 5 (entget (ssname ss 0)))) listOfHandls))
        )
    )
    (reverse listOfHandls)
)

Sea-Haven
Mentor
Mentor

Good to here its working something about closed ploygon hence last pt is 1st point

0 Likes

caddhelp
Explorer
Explorer

"_CP" for the win!

0 Likes