Tharwat Posted November 2, 2010 Share Posted November 2, 2010 You can save some headache by just entmod'ing the insertion point instead of deleting and recreating. That's of course much better . So I've been trying to replace the end point of the selected line to be the Block insertion point , but without a pass . Check this out please .... (defun c:THib (/ ss start e ent answer) (if (setq ss (car (entsel "\n Select Line :"))) (progn (setq start (cdr (assoc 10 (setq e (entget ss))))) (setq ent (entmakex (list (cons 0 "INSERT")(cons 2 "ss")(cons 10 start)(cons 50 0)))) (initget "Yes No") (setq answer (getkword "\n Agree with this side [Yes/No] :")) (if (eq answer "No") [color="red"](entmod (subst (cons 11 e) (assoc 10 ent) ent))[/color] (princ))) (princ) )) Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 2, 2010 Share Posted November 2, 2010 That's of course much better . So I've been trying to replace the end point of the selected line to be the Block insertion point , but without a pass . Check this out please .... (defun c:THib (/ ss start e ent answer) (if (setq ss (car (entsel "\n Select Line :"))) (progn (setq start (cdr (assoc 10 (setq e (entget ss))))) (setq ent (entmakex (list (cons 0 "INSERT")(cons 2 "ss")(cons 10 start)(cons 50 0)))) (initget "Yes No") (setq answer (getkword "\n Agree with this side [Yes/No] :")) (if (eq answer "No") [color="red"](entmod (subst (cons 11 e) (assoc 10 ent) ent))[/color] (princ))) (princ) )) (cons 10 e) instead of (cons 11 e) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 2, 2010 Share Posted November 2, 2010 Still does not work with entmod function . Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 2, 2010 Share Posted November 2, 2010 Still does not work with entmod function .You are trying to entmod an entity, not the entity's data.Here's a little cleaner option: (defun c:Test (/ e b) (and (setq e (car (entsel "\nSelect line: "))) (setq b (entget (entmakex (list '(0 . "INSERT") (cons 2 "P6") (assoc 10 (entget e)))))) (eq "Yes" (progn (initget 0 "Yes No") (getkword "\nSwap end points? [Yes/No] <No>: "))) (entmod (subst (cons 10 (cdr (assoc 11 (entget e)))) (assoc 10 b) b)) ) (princ) ) Change to block to whatever, I just typed the first block name I could think of. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 2, 2010 Share Posted November 2, 2010 Wonderful Alanjt. The way you added the *entget* before *entmakex* is really very smart which would give us the control of the entity that just have inserted. So here are the codes after the correction . (defun c:THib (/ ss1 ent e answer) (if (setq ss1 (car (entsel "\n Select Line :"))) (setq ent (entget (entmakex (list (cons 0 "INSERT")(cons 2 "ss") (cons 10 (cdr (assoc 10 (setq e (entget ss1))))) )))) (princ) ) (initget "Yes No") (setq answer (getkword "\n Agree with this side [Yes/No] :")) (if (eq answer "No") (entmod (subst (cons 10 (cdr (assoc 11 e))) (assoc 10 ent) ent)) (princ)) (princ) ) Thank you so much Alanjt for your help and clarification as well. Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 2, 2010 Share Posted November 2, 2010 Wonderful Alanjt. The way you added the *entget* before *entmakex* is really very smart which would give us the control of the entity that just have inserted. So here are the codes after the correction . (defun c:THib (/ ss1 ent e answer) (if (setq ss1 (car (entsel "\n Select Line :"))) (setq ent (entget (entmakex (list (cons 0 "INSERT")(cons 2 "ss") (cons 10 (cdr (assoc 10 (setq e (entget ss1))))) )))) (princ) ) (initget "Yes No") (setq answer (getkword "\n Agree with this side [Yes/No] :")) (if (eq answer "No") (entmod (subst (cons 10 (cdr (assoc 11 e))) (assoc 10 ent) ent)) (princ)) (princ) ) Thank you so much Alanjt for your help and clarification as well. You should really study my code. You could save yourself some legwork. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 2, 2010 Share Posted November 2, 2010 You should really study my code. You could save yourself some legwork. I do appreciate your point of view, and your way of coding is really very rare and genious, undoubtly. I tried to constuct the codes as the way you made it .... (defun c:THib (/ ss1 ent e) (and (setq ss1 (car (entsel "\n Select Line :"))) (setq ent (entget (entmakex (list (cons 0 "INSERT")(cons 2 "ss") (cons 10 (cdr (assoc 10 (setq e (entget ss1))))))))) (eq "No" (progn (initget 0 "No Yes")(getkword "\n Agree with this side [Yes/No] <Yes>:"))) (entmod (subst (cons 10 (cdr (assoc 11 e))) (assoc 10 ent) ent))) (princ) ) Many thanks. Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 2, 2010 Share Posted November 2, 2010 I do appreciate your point of view, and your way of coding is really very rare and genious, undoubtly. I tried to constuct the codes as the way you made it .... (defun c:THib (/ ss1 ent e) (and (setq ss1 (car (entsel "\n Select Line :"))) (setq ent (entget (entmakex (list (cons 0 "INSERT")(cons 2 "ss") (cons 10 (cdr (assoc 10 (setq e (entget ss1))))))))) (eq "No" (progn (initget 0 "No Yes")(getkword "\n Agree with this side [Yes/No] <Yes>:"))) (entmod (subst (cons 10 (cdr (assoc 11 e))) (assoc 10 ent) ent))) (princ) ) Many thanks. All you did was copy my code and change prompts. I want to make sure you understand why I did what I did, not just do what I did. The code is far from perfect, it can easily fail if the block is unable to be created or the object selected is not a line. I would def. check to make sure the block exists and the object is a line. Try and see if you can figure out how to make it work from the first piece of code I posted (automatically derive the closest end point. Hint: Use the point returned from (entsel) as your comparison point for closeness. Quote Link to comment Share on other sites More sharing options...
Guest cad2007 Posted November 3, 2010 Share Posted November 3, 2010 i am tried but error is came........... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 3, 2010 Share Posted November 3, 2010 i am tried but error is came........... What did you do, and what kind of error you have received ? 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.