Tharwat Posted June 21, 2010 Share Posted June 21, 2010 Hi , the following Lisp is working well, but I want to add alert function to it if user select something else other than a block .... How? (defun c:ib (/ a blo) (prompt "The Block you select will be inserted") (setq a (cdr(assoc 2 (entget(car(entsel"\nSelect a Block: ")))))) (while (setq blo(getpoint"\nInsertion Point :")) (command "_insert" a blo "" "" "" )) (princ "Written by Tharwat") (princ)) Thanks & regards Tharwat is here Quote Link to comment Share on other sites More sharing options...
jammie Posted June 21, 2010 Share Posted June 21, 2010 Maybe this could give you some ideas for your own routine (defun c:ib (/ elist etype input) (if (setq input (car (entsel"\nSelect a Block: "))) (progn (setq elist (entget input)) (setq etype (cdr (assoc 0 elist))) (if (= etype "INSERT") (alert (strcat etype " , {"(cdr (assoc 2 elist)) "} selected ")) (alert (strcat etype " selected")) ) ) (alert "No point picked") ) ) Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 21, 2010 Share Posted June 21, 2010 By using SSGET function will be able to constrain user selection using a filter: (ssget ":S" '((0 . "INSERT"))) Regards, Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2010 Author Share Posted June 21, 2010 Maybe this could give you some ideas for your own routine (defun c:ib (/ elist etype input) (if (setq input (car (entsel"\nSelect a Block: "))) (progn (setq elist (entget input)) (setq etype (cdr (assoc 0 elist))) (if (= etype "INSERT") (alert (strcat etype " , {"(cdr (assoc 2 elist)) "} selected ")) (alert (strcat etype " selected")) ) ) (alert "No point picked") ) ) Thank you so much jammie ,you made my routine attractive Best Regards, Tharwat Quote Link to comment Share on other sites More sharing options...
jammie Posted June 21, 2010 Share Posted June 21, 2010 Thank you so much jammie ,you made my routine attractive Best Regards, Tharwat Your welcome, glad to help Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2010 Author Share Posted June 21, 2010 By using SSGET function will be able to constrain user selection using a filter: (ssget ":S" '((0 . "INSERT"))) Regards, Thanks for your reply, But I wonder how to use the ssget for filtering instead of entget in my case .... what you think....? Best Regards Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 21, 2010 Share Posted June 21, 2010 Thanks for your reply, But I wonder how to use the ssget for filtering instead of entget in my case .... what you think....? How about below example? (defun c:ib( / OldOsnap InsPoint theBlock ) (setvar "CMDECHO" 0) (setq OldOsnap (getvar "OSMODE")) (prompt "\nThe Block you select will be inserted: ") (if (setq theBlock (ssget ":S" '((0 . "INSERT")))) (progn (setq theBlock (cdr (assoc 2 (entget (ssname theBlock 0))))) (while (setq InsPoint (getpoint "\nInsertion Point :")) (setvar "OSMODE" 0) (command "_INSERT" theBlock InsPoint "" "" "") (setvar "OSMODE" OldOsnap) ) ) (prompt "\Nothing selected!") ) (setvar "OSMODE" OldOsnap) (princ) ) Regards, Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2010 Author Share Posted June 21, 2010 How about below example? (defun c:ib( / OldOsnap InsPoint theBlock ) (setvar "CMDECHO" 0) (setq OldOsnap (getvar "OSMODE")) (prompt "\nThe Block you select will be inserted: ") (if (setq theBlock (ssget ":S" '((0 . "INSERT")))) (progn (setq theBlock (cdr (assoc 2 (entget (ssname theBlock 0))))) (while (setq InsPoint (getpoint "\nInsertion Point :")) (setvar "OSMODE" 0) (command "_INSERT" theBlock InsPoint "" "" "") (setvar "OSMODE" OldOsnap) )) (prompt "\Nothing selected!") ) (setvar "OSMODE" OldOsnap) (princ) ) Regards, It is marvelous, and also smart way in looping the Lisp. Thank you so much for your concern. Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 21, 2010 Share Posted June 21, 2010 To emulate entsel even closer, use: (ssget "_+.:E:S" '((0 . "INSERT"))) 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.