Selecting blocks by name

Selecting blocks by name

Anonymous
Not applicable
917 Views
6 Replies
Message 1 of 7

Selecting blocks by name

Anonymous
Not applicable

Dear Experts,

 

I have lisp code that can select the blocks entire drawing, But instead of that I need to select particular WINDOW area. Requesting to change the code as per requirement

(vl-load-com)

(defun c:SBN ( / bn ss i sn)
  (if (and (setq bn (getstring "Block name: "))
	   (setq ss (ssget "_X" (list '(0 . "INSERT")
				      (cons 2 (strcat "`*U*," bn))))))
    (repeat (setq i (sslength ss))
      (if (not (wcmatch (vla-get-effectivename (vlax-ename->vla-object (setq sn (ssname ss (setq i (1- i)))))) bn))
	(ssdel sn ss))))
  (if ss (sssetfirst nil ss))
  (princ)
)

Thanks & Regards,

T.Brahmanandam 

0 Likes
Accepted solutions (1)
918 Views
6 Replies
Replies (6)
Message 2 of 7

rkmcswain
Mentor
Mentor

Your (ssget) function is using the "_X" selection method, which is "entire database".

Sounds like you want to use the "_W" selection method. 

Example: 

(ssget "_W" '(0 0) '(5 5))

 

See more here: http://help.autodesk.com/view/ACD/2021/ENU/?guid=GUID-0F37CC5E-1559-4011-B8CF-A3BA0973B2C3

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 7

Anonymous
Not applicable

Sir, myself tried with that code also, but not able to perform the operation, Can you please edit the code as per my requirement?

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... Can you please edit the code as per my requirement?


Not without knowing what your "particular WINDOW are" is.

Kent Cooper, AIA
0 Likes
Message 5 of 7

Anonymous
Not applicable

Sorry Sir,

 

It's my mistake, while wiritng.

 

It is not "Particular Window", It's only "User Window Selection"

0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....

It is not "Particular Window", It's only "User Window Selection"


Then just remove the "_X", and it will find qualifying things among the User selection [whether by Window or otherwise], rather than in the entire drawing.

Kent Cooper, AIA
Message 7 of 7

Anonymous
Not applicable

Working nicely Sir.

 

I got the solution , Feeling happy.

0 Likes