Jump to content

Alert function to Lisp wanted


Tharwat

Recommended Posts

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

Link to comment
Share on other sites

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")
     )
   )

Link to comment
Share on other sites

By using SSGET function will be able to constrain user selection using a filter:

 

(ssget ":S" '((0 . "INSERT")))

 

Regards,

Link to comment
Share on other sites

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 :D

Best Regards,

Tharwat

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...