Jump to content

Recommended Posts

Posted

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

Posted

Look into using ssget instead.

Posted

I have dynamic blocks so I prefer to use QSELECT.

Posted

QSelect doesn't have a commandline option.

Posted

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

  • 2 weeks later...
Posted

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

Posted

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

Posted

Hi

 

Your question is not clear and to whom it is dedicated ?

 

clarify please

 

Tharwat

Posted
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.

  • 2 years later...
Posted

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 ?

Posted (edited)
(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
Posted

Wow - thanks for the swift response . Just a snag "; error: no function definition: VLAX-ENAME->VLA-OBJECT"

Posted

missing (vl-load-com).. post updated. try it now

Posted
: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

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...