Francisco Ervedal Posted July 21, 2011 Share Posted July 21, 2011 I am a beginner in autocad and in urgent need of your help. What is the code in AutoLISP to select objects on a layer and change its properties (color, text height, layer, etc.). Thanks for your help. Quote Link to comment Share on other sites More sharing options...
irneb Posted July 21, 2011 Share Posted July 21, 2011 Welcome to CT! Hope you get what you're after here! ssget is used to make a selection. Check the help on that (preferably open VLIDE type ssget, put the cursor on that word and press Ctrl+F1). The "simplest" way to do it would be to have ssget select the entities you want and then send that to the change command. It's not necessarily the "best" solution, but gives a simple starting point for you: (if (setq ss (ssget "_X" '((8 . "LayerName")))) (command "._CHANGE" ss "" "_Properties" "_Color" "ByLayer" "_Layer" "NewLayerName" "") ) As for text height, that's a bit more complex. In lisp you can only modify one entity at a time, but you can set lisp to perform that modification for each entity in the selection set. For this you'll need to loop through the selection set, get the ename & dxf codes of each in turn. Substitute the 40 dxf code with the new height. Then use entmod to apply the change to the entity: (setq pos 0) (while (< pos (sslength ss)) (setq ename (ssname ss pos)) (setq dxfdata (entget ename)) (if (eq (cdr (assoc 0 dxfdata)) "TEXT") (entmod (subst '(40 . 200.0) (assoc 40 dxfdata) dxfdata)) ) (setq pos (1+ pos)) ) You could do similar for the other properties as well. You'll need to look into the DXF help, each entity type has some different codes. That's why I put that if to check if the current entity extracted from the selection set is a TEXT entity - note you may need to modify to also work with MTEXT. Quote Link to comment Share on other sites More sharing options...
Francisco Ervedal Posted July 21, 2011 Author Share Posted July 21, 2011 Thanks. Best regards. 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.