Jump to content

Qselect


alijahed

Recommended Posts

Hi All,

 

how can I use QSELECT command in lisp and set its parameters to select a specific block through block name filter.

 

Cheers

 

Ali

Link to comment
Share on other sites

If you want to roll your own, you can specify the block name and cycle through a selection (removing what doesn't match the vla-get-effectivename) and the use sssetfirst to select what's left.

 

(ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," [color=Red]name[/color]))))

 

This will select all dynamic blocks and blocks matching the specified name. From there, you can cycle (what I said above).

Link to comment
Share on other sites

  • 2 weeks later...

After weeks I came back to this and I confused!

so it is better to simplify the situation.

Let's say I have a dynamic block inserted on the screen and I know the name of the dynamic block.

How can I select that dynamic block by it's name?

 

Cheers

 

Ali

Link to comment
Share on other sites

Ali,

 

you can filter any Entity you want with Autolisp, but to put selection on hold is not that needed, so there must be an action to do after selecting any Entity.

 

For example this lisp is made by me it will ask you to select a block and it will insert the selected Block with non stop action until you hit enter. Try it.

(defun c:qs (/ a ins)
(setq b (cdr(assoc 2 (entget(car(entsel"\nSelect a Block: "))))))
(while (setq ins (getpoint"\n Insertion point <enter to exit> :"))
(command "_insert" b ins  "" "" "" ))
(princ "Written by Tharwat")
(princ))

 

Tharwat

Link to comment
Share on other sites

How can I select that dynamic block by it's name?

 

When a dynamic blocks properties are altered, it becomes an anonymous block, therefore you are unable to select it using its name in an ssget filter, rather, use the filter that Alan has suggested, and filter through the resultant set (should there be one), and check against the EffectiveName property.

Link to comment
Share on other sites

  • 2 years later...

Sorry to gravedig here . I need to be able to select a block and have AutoCAD tell me how many times that block has been placed in the drawing file. Tharwat's routine looks like it could be altered to do this - but I have no idea how to do so. Can anyone assist please ?

Link to comment
Share on other sites

(defun  c:test (/ efname ob blks cnt i)(vl-load-com)
(setq  efname
  (lambda (k)
    (vla-get-effectivename
      (if (eq (type k) 'ENAME )
      (vlax-ename->vla-object k) k)
      )
    )
 )
 (while (setq ob (ssget "_:S:E" '((0 . "INSERT"))))
   (setq cnt 0)
   (if (setq blks (ssget "_X"
         (list '(0 . "INSERT")
           (cons 2
             (strcat (setq bn (strcase (efname (ssname ob 0)))) ",`*U*"
               )
             )
           )
         ))
     (progn
     (repeat (setq i (sslength blks))
       	(if (eq (strcase (efname (ssname blks (setq i (1- i))  ))) bn)
                 	(setq cnt (1+ cnt))))	
       (alert
         (strcat "There are "
           (itoa cnt) " \"" bn
           "\" Block(s) on this drawing file:"
           )
         )
       )
     )
   )
 (princ)
 )

Edited by pBe
Link to comment
Share on other sites

:notworthy: - many thanks . Fantastic.

 

You are welcome. :)

 

But really, If you read thru the thread you will notice that everything on that code came from the previous response.

 

Have fun

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...