eyeofnewt555 Posted January 11, 2017 Share Posted January 11, 2017 If only QSelect weren't lying when it gives the option to search "Entire Drawing." As the title says, I'd like to be able to grab all instances of an object (typically a block) across multiple layout tabs in paper space (if it were in model, this wouldn't be a problem). The end goal being to change a property across the board. I know there's GATTE if it's a block attribute that needs changing, but that's not always the case. Ideally, some way to grab all instances with optional filters would be great. Really, I just want QSelect to have better functionality. It looks like someone addressed it here, but I'm not having any success with that method. Thanks for any help! Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 11, 2017 Share Posted January 11, 2017 Whats the name of the block, is it dynamic? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 11, 2017 Share Posted January 11, 2017 Then what to do after selecting these Block references? Quote Link to comment Share on other sites More sharing options...
eyeofnewt555 Posted January 11, 2017 Author Share Posted January 11, 2017 The name will change. I'm not looking for a one time option. I guess prompting to select an instance of the block or type a name would be great. Mostly the blocks will be static, but could occasionally be dynamic, in which case it would be helpful to be able to filter the selection based on which state the block is in. Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 11, 2017 Share Posted January 11, 2017 This should grip all blocks in the drawing, with the same name: (defun C:test ( / blk SS nSS i e ) (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (setq blk (car (entsel "\nSelect block to filter <exit>: "))) (cond ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0)) ((and blk (/= "INSERT" (cdr (assoc 0 (entget blk))))) (princ)) (blk (setq blk (vla-get-EffectiveName (vlax-ename->vla-object blk))) (setq SS (ssget "_X" (list (cons 0 "INSERT")))) (setq nSS (ssadd)) (repeat (setq i (sslength SS)) (setq e (ssname SS (setq i (1- i)))) (and (eq blk (vla-get-EffectiveName (vlax-ename->vla-object e))) (ssadd e nSS) ) ) (sssetfirst nil nSS) (setvar 'errno 52) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
eyeofnewt555 Posted January 11, 2017 Author Share Posted January 11, 2017 Any number of things. Delete them all (I know there are other ways to do this too), change their layer (or any other property/attribute), maybe even move them all using displacement (lets say you've got a scale bar on multiple layouts that now needs to be an inch to the left on every sheet). I know there are generally work arounds for most of these, but it'd be handy to have one command to do it all. Quote Link to comment Share on other sites More sharing options...
eyeofnewt555 Posted January 11, 2017 Author Share Posted January 11, 2017 Perfect! It looks like it kicks out everything that's not on the current layout if you try to run a command on the selection set. But changing anything in the properties panel works like a charm--which is pretty much all I need. Thanks a ton, Grrr! Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 11, 2017 Share Posted January 11, 2017 Perfect! It looks like it kicks out everything that's not on the current layout if you try to run a command on the selection set. But changing anything in the properties panel works like a charm--which is pretty much all I need. I didn't knew about that, but the code is supposed to grip every occurence in all layouts. BTW that suggestion you addressed should work for non-dynamic blocks. Thanks a ton, Grrr! You're welcome! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 12, 2017 Share Posted January 12, 2017 I do some stuff like this but in a different way just atke advantage of Setvar CTAB which can open every layout 1 at a time and do something also adding the 410 filter. (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (foreach tabname plotabs ; no need to regen each sheet (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname)))) and so on do your move etc as a defun at this point Quote Link to comment Share on other sites More sharing options...
eyeofnewt555 Posted January 12, 2017 Author Share Posted January 12, 2017 Thanks, BigAl! If I ever get half decent at writing LISPs, I'll try that out. It sounds like it could be neat. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 13, 2017 Share Posted January 13, 2017 No worries an example Issued for construction.lsp Quote Link to comment Share on other sites More sharing options...
crass Posted February 22, 2017 Share Posted February 22, 2017 This should grip all blocks in the drawing, with the same name: (defun C:test ( / blk SS nSS i e ) (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (setq blk (car (entsel "\nSelect block to filter <exit>: "))) (cond ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0)) ((and blk (/= "INSERT" (cdr (assoc 0 (entget blk))))) (princ)) (blk (setq blk (vla-get-EffectiveName (vlax-ename->vla-object blk))) (setq SS (ssget "_X" (list (cons 0 "INSERT")))) (setq nSS (ssadd)) (repeat (setq i (sslength SS)) (setq e (ssname SS (setq i (1- i)))) (and (eq blk (vla-get-EffectiveName (vlax-ename->vla-object e))) (ssadd e nSS) ) ) (sssetfirst nil nSS) (setvar 'errno 52) ) ) ) (princ) ) Hello. This looks to be exactly what I need. I created a lisp of the above code and used APPLOAD to load it. I am now unsure how to initiate the command. Any help would be appreciated. This could save me a lot of time. I need to change the layer of a block in 20 different layout tabs across 15 different sheet sets. Thanks! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 22, 2017 Share Posted February 22, 2017 Something like this (defun AH:uptitle ( / doc lay plotabs newlay bname ss1) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) ; for (setq bname (vla-get-name (vlax-ename->vla-object (car (entsel "\nPick block"))))) (setq newlay (getstring "Enter layer name")) (foreach tabname plotabs (if (/= "Model" tabname) (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname)))) ) ; if (repeat (setq x (sslength ss1)) (vla-put-layer (vlax-ename->vla-object (ssname SS1 (setq x (- x 1)))) newlay) ) ; repeat (setq ss1 nil) ) ; for ) ; defun (AH:uptitle) Quote Link to comment Share on other sites More sharing options...
crass Posted February 23, 2017 Share Posted February 23, 2017 Thank you for the response. I will try this out tomorrow. Quote Link to comment Share on other sites More sharing options...
gonecrawfishin Posted January 15, 2020 Share Posted January 15, 2020 Hi all, Does anyone have a similar LISP that works for all types of objects, not just blocks? I'm looking to do some purging, and want to select everything on a particular layer across all paperspaces. Thanks! Quote Link to comment Share on other sites More sharing options...
dlanorh Posted January 16, 2020 Share Posted January 16, 2020 5 hours ago, gonecrawfishin said: Hi all, Does anyone have a similar LISP that works for all types of objects, not just blocks? I'm looking to do some purging, and want to select everything on a particular layer across all paperspaces. Thanks! Try (setq ss (ssget "_X" (list (cons 8 layernames))));; eg layernames = "0,DEFPOINTS,....." Quote Link to comment Share on other sites More sharing options...
gonecrawfishin Posted January 16, 2020 Share Posted January 16, 2020 Thanks dlanorh. I tried that, but then the command line returns <Selection set: 23> , but I don't actually have any objects selected. Next, I tried DELETE in teh command line, and then I pasted that script above. Command line said <selection set: 2f> 16 found 16 were not in current space I'm not really sure what it's doing, or why it's returning 23 in one case, 16 in another. Thoughts? Quote Link to comment Share on other sites More sharing options...
dlanorh Posted January 16, 2020 Share Posted January 16, 2020 3 hours ago, gonecrawfishin said: Thanks dlanorh. I tried that, but then the command line returns <Selection set: 23> , but I don't actually have any objects selected. Next, I tried DELETE in teh command line, and then I pasted that script above. Command line said <selection set: 2f> 16 found 16 were not in current space I'm not really sure what it's doing, or why it's returning 23 in one case, 16 in another. Thoughts? The highlighted item is the name of the selection sets Try this (defun c:test (/ ss) (setq ss (ssget "_X" '((0 . "0,DEFPOINTS")))) ;; This should select every item on layers "defpoints" and "0". Items will not be highlighted (if ss ;;TEST if anything selected (princ (sslength ss)) ;; If YES This will tell you how many items are in the selection set (princ "Selection set empty") );end_if (princ) );end_defun Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 16, 2020 Share Posted January 16, 2020 (edited) 4 hours ago, gonecrawfishin said: Thanks dlanorh. I tried that, but then the command line returns <Selection set: 23> , but I don't actually have any objects selected. Next, I tried DELETE in teh command line, and then I pasted that script above. Command line said <selection set: 2f> 16 found 16 were not in current space I'm not really sure what it's doing, or why it's returning 23 in one case, 16 in another. Thoughts? If you want to delete items on all layouts, try something like this: (defun c:foo (/ s) (if (setq s (ssget "_X" '((8 . "0,DEFPOINTS"))));; Items on layer 0 and defpoints (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s))) (vl-catch-all-apply 'vla-delete (list o)) ) ) (princ) )(vl-load-com) Note that @dlanorh latest ssget filter will always return nothing since he's using code 0 rather than 8 for layers. Edited January 16, 2020 by ronjonp 1 Quote Link to comment Share on other sites More sharing options...
dlanorh Posted January 16, 2020 Share Posted January 16, 2020 11 minutes ago, ronjonp said: If you want to delete items on all layouts, try something like this: (defun c:foo (/ s) (if (setq s (ssget "_X" '((8 . "0,DEFPOINTS"))));; Items on layer 0 and defpoints (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s))) (vl-catch-all-apply 'vla-delete (list o)) ) ) (princ) )(vl-load-com) Note that @dlanorh latest ssget filter will always return nothing since he's using code 0 rather than 8 for layers. Doh! 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.