YZ Posted December 6, 2016 Share Posted December 6, 2016 We are trying to write a lisp that will set all blocks in a dwg to an X, Y, and Z scale value of 1. By my reckoning it should work. But it only applies the scale change to one block in the dwg - the latest one that was inserted. Do I need to loop through the selection set? I assumed it would apply the change to all in the selection automatically. Thanks for any help. See below for code, and see attached a sample dwg that shows one block only changing. (defun c:SCB () ;(setvar "qaflags" 1) ;below selects all blocks (setq ALLBLOCKS (ssget "X" (LIST (cons 0 "INSERT")))) ;(command "select" allblocks)) (if (progn (setq blocks (ssname ALLBLOCKS 0)) (entmod ; modifies the properties of the entity (append ; combines the list (entget blocks); indicates what entity to edit (list ; create a list of properties to change (cons 41 1) (cons 42 1) (cons 43 1) ) ) ) (entupd blocks); updates the block ) (prompt "\nNo blocks in drawing!") ) (princ) ;(setvar "qaflags" 0) ) 16-027Hkjkl.dwg Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 6, 2016 Share Posted December 6, 2016 Yes, of course you need to loop over the selection set. Plenty of examples out there. Just search. Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 6, 2016 Share Posted December 6, 2016 Heres a handy tutorial about how to iterate through a seleciton set. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 7, 2016 Share Posted December 7, 2016 Try this ;below selects all blocks (setq ALLBLOCKS (ssget "X" (LIST (cons 0 "INSERT")))) ;(command "select" allblocks)) (if (progn (repeat (setq x (sslength allblocks))) (setq blocks (ssname ALLBLOCKS (setq x (- x 1)))) (entmod ; modifies the properties of the entity (append ; combines the list (entget blocks); indicates what entity to edit (list ; create a list of properties to change (cons 41 1) (cons 42 1) (cons 43 1) ) ) ) (entupd blocks); updates the block ) ) ; repeat ? (prompt "\nNo blocks in drawing!") ) ; progn (princ) ;(setvar "qaflags" 0) ) ; if Its just me but I put ) ; if its so I can keep track of the closing pairs makes it easier to add to code like this. Quote Link to comment Share on other sites More sharing options...
YZ Posted January 9, 2017 Author Share Posted January 9, 2017 Thanks BigAl, was able to put something together from your comment and the tutorial above. 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.