Dayananda Posted February 27, 2020 Share Posted February 27, 2020 (entmod (subst (cons 10 LeftEnd1)(assoc 10 entlist) entlist)) (entmod (subst (cons 11 LeftEnd2)(assoc 11 entlist) entlist)) When I apply above codec to a vertical line it does not work properly. How can I add above codes to a one code. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted February 27, 2020 Share Posted February 27, 2020 Make yourself a function (defun dy:entmod (code val lst) (entmod (subst (cons code val) (assoc code lst) lst))) then (setq e_lst (entget ent)) (foreach x (list (list 10 leftEnd1) (list 11 leftend2)) (dy:entmod (car x) (cadr x) e_lst)) 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2020 Share Posted February 27, 2020 (edited) The reason that your original code does not work as expected is because the second entmod expression is still operating on the original DXF list bound to the variable entlist and therefore you will receive a result whereby DXF group 11 has the new value, and DXF group 10 has reverted back to its original value. There are many ways around this, but the easiest & most readable might be: (setq entlist (subst (cons 10 LeftEnd1) (assoc 10 entlist) entlist) entlist (subst (cons 11 LeftEnd2) (assoc 11 entlist) entlist) ) (entmod entlist) Alternatively, you can nest the subst expressions, e.g.: (entmod (subst (cons 11 LeftEnd2) (assoc 11 entlist) (subst (cons 10 LeftEnd1) (assoc 10 entlist) entlist))) Edited February 27, 2020 by Lee Mac 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 27, 2020 Share Posted February 27, 2020 (edited) This should work too: (entmod (append entlist (list (cons 10 leftend1) (cons 11 leftend2)))) Edited February 27, 2020 by ronjonp 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2020 Share Posted February 27, 2020 3 hours ago, ronjonp said: This should work too: (entmod (append entlist (list (cons 10 leftend1) (cons 11 leftend2)))) Just be aware that that method only works with certain entities, and won't work with entities which require subclass markers in the DXF data. 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 27, 2020 Share Posted February 27, 2020 Good to know! 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.