alijahed Posted June 7, 2010 Share Posted June 7, 2010 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 Quote Link to comment Share on other sites More sharing options...
lpseifert Posted June 7, 2010 Share Posted June 7, 2010 Look into using ssget instead. Quote Link to comment Share on other sites More sharing options...
alijahed Posted June 8, 2010 Author Share Posted June 8, 2010 I have dynamic blocks so I prefer to use QSELECT. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 QSelect doesn't have a commandline option. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 8, 2010 Share Posted June 8, 2010 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). Quote Link to comment Share on other sites More sharing options...
alijahed Posted June 17, 2010 Author Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2010 Share Posted June 17, 2010 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2010 Share Posted June 17, 2010 Hi Your question is not clear and to whom it is dedicated ? clarify please Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2010 Share Posted June 17, 2010 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. Quote Link to comment Share on other sites More sharing options...
sinnerboy Posted October 8, 2012 Share Posted October 8, 2012 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 ? Quote Link to comment Share on other sites More sharing options...
pBe Posted October 8, 2012 Share Posted October 8, 2012 (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 October 8, 2012 by pBe Quote Link to comment Share on other sites More sharing options...
sinnerboy Posted October 8, 2012 Share Posted October 8, 2012 Wow - thanks for the swift response . Just a snag "; error: no function definition: VLAX-ENAME->VLA-OBJECT" Quote Link to comment Share on other sites More sharing options...
pBe Posted October 8, 2012 Share Posted October 8, 2012 missing (vl-load-com).. post updated. try it now Quote Link to comment Share on other sites More sharing options...
sinnerboy Posted October 8, 2012 Share Posted October 8, 2012 - many thanks . Fantastic. Quote Link to comment Share on other sites More sharing options...
pBe Posted October 8, 2012 Share Posted October 8, 2012 - 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.