command: hole
Specify radius <2.0>:
Pick point:
Next point:
(setq sd (getreal (strcat "\nSpecify Radius <"(rtos $sd 2 1)">: ")))
how to put that in this hole.lsp
(defun c:HOLE(/ circle_2 pt1)
(if (setq pt1 (getpoint "\nSelect Pick Point: "))
(progn (command "circle" pt1 sd)
(command "circle" pt1 sd)
(setq circle_2 (entlast))
(load "extrim")
(acet-error-init (list
(list "cmdecho" 0
"highlight" 0
"regenmode" 1
"osmode" 0
"ucsicon" 0
"offsetdist" 0
"attreq" 0
"plinewid" 0
"plinetype" 1
"gridmode" 0
"celtype" "CONTINUOUS"
"ucsfollow" 0
"limcheck" 0
)
T ;flag. True means use undo for error clean up.
'(if redraw_it (redraw na 4))
);list
);acet-error-init
(etrim circle_2 pt1)
(acet-error-restore)
(entdel circle_2)))
(princ)
)
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Perhaps something like this
(defun c:HOLE(/ *error* circle_2 osm pt1) (defun *error* (msg) (acet-error-restore) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq osm (getvar 'OSMODE)) (load "extrim") (acet-error-init (list (list "cmdecho" 0 "highlight" 0 "regenmode" 1 "osmode" 0 "ucsicon" 0 "offsetdist" 0 "attreq" 0 "plinewid" 0 "plinetype" 1 "gridmode" 0 "celtype" "CONTINUOUS" "ucsfollow" 0 "limcheck" 0 ) T ;flag. True means use undo for error clean up. '(if redraw_it (redraw na 4)) );list );acet-error-init (or $sd (setq $sd 2.0)) (setq sd (getreal (strcat "\nSpecify Radius <"(rtos $sd 2 1)">: "))) (if (null sd)(setq sd $sd)(setq $sd sd)) (while (and (setvar 'OSMODE osm) (setq pt1 (getpoint "\nSelect Pick Point: ")) ) (setvar 'OSMODE 0) (command "circle" pt1 sd) (setq circle_2 (entlast)) (etrim circle_2 pt1) );; while (acet-error-restore) (princ) )
Hope that helps
Henrique
agent,
I just thought I'd explain the HOW of including a default setting in the prompt (which is what you're looking to do and what Henrique has provided for you).
;This line sets $sd to a default value of ;2.0 if there's not one already set. (or $sd (setq $sd 2.0)) ;Then display the prompt and wait for a response. (setq sd (getreal (strcat "\nSpecify Radius <"(rtos $sd 2 1)">: "))) ;If the user pressed enter (to select the default) sd will be null, ;so set sd to use the default value from $sd. ;If the user entered a new value instead of accepting the default, ;then set that to be the new default for the next time. (if (null sd)(setq sd $sd)(setq $sd sd))
And for future knowledge, if you can provide a brief description of your issue in the subject (as opposed to Help Please), you will likely get better responses. I know that if I've got a couple min to spare (such as I'm waiting at my desk for someone so I can't really start a new task), I'll visit the forums and skim through the message list looking for something that I think I can answer relatively quickly. In such a case, I typically wouldn't click on the "Help Please" subject as I have NO IDEA what it's about -- I leave those for when I have more time to "just browse". Instead, I'll click on the message with a subject that does look like something I can help with.
If I were a betting man, I'd bet that there are others out there who do the same thing. I think you just got lucky here in that Henrique had more time to spare.
Don Ireland
Engineering Design Technician
thanks for the solution and time for both of you guys..learning lisp its not easy without your help i hope someday i can help other people about lisp..
Don Ireland
Engineering Design Technician
Don Ireland
Engineering Design Technician
@hmsilva wrote:
Perhaps something like this
.... (or $sd (setq $sd 2.0)) (setq sd (getreal (strcat "\nSpecify Radius <"(rtos $sd 2 1)">: "))) (if (null sd)(setq sd $sd)(setq $sd sd)) ........
Here's another [and shorter, omitting the comments] way that I usually do that default thing for numerical values, which requires neither pre-(setq)ing a default value if it's not already there nor using a temporary-value [sd above] variable:
(setq $sd
(cond
((getreal (strcat "\nSpecify Radius <" (if $sd (rtos $sd 2 1) "2.0") ">: ")))
; User-types-value condition [nil on Enter]; offer prior value as default if present, 2.0 on first use
($sd); User hit Enter with prior value [subsequent use]
(2.0); User hit Enter without prior value [first use]
); end cond
); end setq