Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HELP PLEASE

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
agent47x
283 Views, 6 Replies

HELP PLEASE

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

6 REPLIES 6
Message 2 of 7
hmsilva
in reply to: agent47x

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

EESignature

Message 3 of 7
doni49
in reply to: hmsilva

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




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 4 of 7
agent47x
in reply to: doni49

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

Message 5 of 7
doni49
in reply to: agent47x

If you're trying to learn autodesk, there are three tutorial sites that I'll point you to:

www.jefferypsanders.com
www.afraliplsp.net
www.lee-mac.com (provided by our very own @lee-mac)


Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 6 of 7
doni49
in reply to: agent47x

Autocorrect got me that should have said "learning autolisp".


Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 7 of 7
Kent1Cooper
in reply to: hmsilva


@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

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost