Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ssget off screen selection

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
DonatasAzaravicius
540 Views, 4 Replies

ssget off screen selection

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)?

Tags (1)
Labels (1)
4 REPLIES 4
Message 2 of 5

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

 

 

 

Message 3 of 5

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)
)
Message 4 of 5

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

Message 5 of 5

"_CP" for the win!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report