PDA

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



jamesfui
17th Dec 2011, 02:37 pm
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)

pBe
17th Dec 2011, 02:50 pm
(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 :)

alanjt
17th Dec 2011, 03:06 pm
I didn't realize multiplying and dividing by 2 was so difficult. :P

pBe
19th Dec 2011, 06:56 am
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" <female voice>

Dadgad
19th Dec 2011, 07:37 am
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.

nalsur8
20th Dec 2011, 09:53 am
(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)
)