Jump to content

lsp help for prompting circle overall 'diameter' & change as per new value input!


jamesfui

Recommended Posts

hi.. need help on creating lsp that can:

 

> prompt selected circle overall diameter & change to new diameter if new value is inputed! (enter or right click) for no change

 

i tried out the 'change' command for properties, but it only ask for the radius not the diameter...

so need help on a lisp routine that can show/prompt/display diameter right beside the selected circle & if a new value is key in, the circle diameter changes instantly!

 

thanks 8)

Link to comment
Share on other sites

(defun  c:test (/ cir ent z )
 (while (setq cir (ssget ":E:L" '((0 . "CIRCLE"))))
   (setq cur (* (cdr (assoc 40  (setq ent (entget (ssname cir 0))))) 2) )
   (redraw (ssname cir 0) 3)
   (setq
     z (cond
         ((getreal
            (strcat
              "\nEnter diameter[Enter to accept: <"
              (rtos (setq z cur) 2 2)
              ">: "
              )
            )
          )
         (z)
         )
     )
   (entmod
     (subst
       (cons 40 (/ z 2.0))
       (assoc 40 ent)
       ent
       )
     )
   )
 (princ)
 )

 

Almost but not :)

Link to comment
Share on other sites

I didn't realize multiplying and dividing by 2 was so difficult. :P

 

:lol:

 

Could've been worse, the OP coud have ask to prompt for diameter value using Sapi.SpVoice

 

"Enter Diameter or Enter to accept current"

Link to comment
Share on other sites

I didn't realize multiplying and dividing by 2 was so difficult. :P

 

It could be, if you had your precision setting to 10 decimal places, I suppose, and were running custom made drill bits, or using a CNC laser. I use rather mundane metric sizes, and have precision in mms set to no decimal places,which makes it a lot easier. If you forget where you put the lisp, you can select a circle or circles, and find and change the diameter in the QUICKPROPERTIES palette, which I use all the time. Customize so that it shows whatever info you are after, or in the regular PROPERTIES dialog box, under DIAMETER. Using lisp for something like this seems a bit like an exterminator showing up in a tank for a termite problem, IMO. So many ways to go, and yet all roads lead to home.

Link to comment
Share on other sites

(defun C:TEST11 ()
 (defun *error* (msg) (setq *error* nil) (princ))
 (setq cirdia (entsel "\nPick circle to change..."))
 (setq entdia (entget (car cirdia)))
 (setq diarad (cdr (assoc 40 entdia)))
 (setq diame (* diarad 2))
 (setq dia (getreal (strcat "\nEnter new diameter [current <"(rtos diame) ">]:")))
 (prompt "\nSelect circle to change...")
 (setq A (ssget (list (cons '0 "circle")(cons '40 diarad))))
 (setq B (sslength A))
 (setq X 0)
 (repeat B
   (setq NAME (ssname A X))
   (setq PARAM (entget NAME))
   (setq CHECK (cdr (assoc 0 PARAM)))
   (if (/= CHECK "CIRCLE")
     (progn (ssdel NAME A)
   (setq X (1- X)))
   ) ;_ end of if
   (setq X (1+ X))
 ) ;_ end of repeat
 (setq B (sslength A))
 (setq RAD (/ DIA 2))
 (setq NEWRAD (cons '40 RAD))
 (setq X 0)
 (repeat B
   (setq NAME (ssname A X))
   (setq PARAM (entget NAME))
   (setq PARAM (subst NEWRAD (assoc 40 PARAM) PARAM))
   (entmod PARAM)
   (setq X (1+ X))
 ) ;_ end of repeat
 (prompt (strcat "Selected object - Qty:"(rtos b) ""))
 (princ)
)

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...