K Baden Posted December 12, 2017 Share Posted December 12, 2017 Good morning! I am trying to get this code to work, but keep getting errors. I basically want something that will grab all blocks named ELEVATION MARKER and change the X, Y, and Z scaled to "1". Anyone have any idea why this isn't working? (defun c:chgscl (/ factr ent) (setq factr 1.0) (IF (setq ss (ssget "_X" '((0 . "INSERT") (2 . "ELEVATION MARKER"))) (setq ent (entget (ssname ss 0))) (setq ent (subst (cons 41 factr) (assoc 41 ent) ent) ent (subst (cons 42 factr) (assoc 42 ent) ent) ent (subst (cons 43 factr) (assoc 43 ent) ent) ) (entmod ent) ) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 12, 2017 Share Posted December 12, 2017 The if function will only accept three arguments: a test argument, a 'then' argument, and optionally, and 'else' argument. Since you wish to evaluated multiple expressions as part of the 'then' argument, you will need to evaluate such expressions using a progn expression which may then be supplied as a single argument to the if function. However, note that even with the syntax corrected, your code will only operate on the first block reference in the selection - to operate on all block references, you will need to iterate over the selection set, perhaps using one of the methods I have described here. Quote Link to comment Share on other sites More sharing options...
K Baden Posted December 12, 2017 Author Share Posted December 12, 2017 Thank you for the advice!! In an attempt to utilize the "while" method, This is what I came up with. It is loading properly, but returning nil and not making any changes. I'm not sure what i've got wrong here. (defun c:chgscl (/ ss factr ent) (setq factr 1.0) (while (setq ss (ssget "_X" '((0 . "INSERT") (2 . "ELEVATION MARKER")))) (setq ent (subst (cons 41 factr) (assoc 41 ent) ent) ent (subst (cons 42 factr) (assoc 42 ent) ent) ent (subst (cons 43 factr) (assoc 43 ent) ent) ) (entmod ent) ) ) Should I perhaps also be using an IF with the PROGN statements along with the While? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 12, 2017 Share Posted December 12, 2017 IMO the code should work, but it will only change the insert entity not any attached attributes. Quote Link to comment Share on other sites More sharing options...
K Baden Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) Should the "while" be moved to after the selection is made? perhaps that is the issue? I'm just not understanding why I get nil everytime i run the command, and it makes no changes. EDIT they are dynamic blocks. will that make a difference? I am also trying to make this scale update in paper space, if that makes any difference Edited December 12, 2017 by K Baden Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 12, 2017 Share Posted December 12, 2017 Oops, wait: you will of course have to iterate over the selection set. (defun c:chgscl ( / ent factr idx ss) (setq factr 1.0) (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "ELEVATION MARKER")))) (repeat (setq idx (sslength ss)) (setq ent (entget (ssname ss (setq idx (1- idx)))) ent (subst (cons 41 factr) (assoc 41 ent) ent) ent (subst (cons 42 factr) (assoc 42 ent) ent) ent (subst (cons 43 factr) (assoc 43 ent) ent) ) (entmod ent) ) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 12, 2017 Share Posted December 12, 2017 Please don't double-post - http://www.cadtutor.net/forum/showthread.php?80714-LISP-Scaling-just-the-quot-x-quot-and-quot-y-quot-axis&p=694813&viewfull=1#post694813 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 13, 2017 Share Posted December 13, 2017 You have double posted you could have just continued on 1st post. Quote Link to comment Share on other sites More sharing options...
K Baden Posted December 13, 2017 Author Share Posted December 13, 2017 That is definitely my bad! I saw a thread I hadn't seen previously after figuring it must be the fact that my blocks are dynamic, and posted there as well. My mistake! 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.