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

Default prompt on enter

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
JCprog
1701 Views, 8 Replies

Default prompt on enter

Hello everyone 🙂

 

I'm trying to make a default prompt selection on my rotation angle but can't seem to make it work. Please help.....Thanks in advance 🙂

 

  (prompt "Select Entities to Rotate")
  (setq ss (ssget))

  (setq num (sslength ss))
  (setq x 0)
  (if ss 
  	(if (setq ang (getreal "\nEnter Rotation Angle [45/90/180] <45>: "))
	  	(repeat num
		  	(setq ename (ssname ss x))
		    (setq elist (entget ename))
			(setq pnt (cdr(assoc 10 elist)))
			(command "Rotate" ename "" pnt ang)
 		    (setq x (1+ x))
	    	)
	  	)
    )
  )

 

8 REPLIES 8
Message 2 of 9
Shneuph
in reply to: JCprog

You can check out Lee Mac's website (link below).  He explains how to do this well..  Use (INITGET...)

 

Prompt With Default

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 9
JCprog
in reply to: Shneuph

Thanks for the reply Shneuph,
I already tried Lee's, somehow cant get it to work.
Message 4 of 9
Lee_Mac
in reply to: JCprog

JCprog wrote:
Thanks for the reply Shneuph,
I already tried Lee's, somehow cant get it to work.

 

There are of course many ways this could be achieved depending on the behaviour you are looking for from the program; since you are restricting the user to angles of 45, 90 or 180, a getkword prompt may be more appropriate, for example:

 

(prompt "Select Entities to Rotate")
(if (setq sel (ssget "_:L"))
    (progn
        (initget "45 90 180")
        (setq ang (atoi (cond ((getkword "\nEnter Rotation Angle [45/90/180] <45>: ")) ("45"))))

        ...
    )
)

 


 

Thank you for the recommendation Shneuph!

 

Message 5 of 9
JCprog
in reply to: Lee_Mac

Thanks for the code Lee but it gives me this error:

; error: bad argument type: fixnump: nil

Message 6 of 9
hmsilva
in reply to: JCprog


@JCprog wrote:

Thanks for the code Lee but it gives me this error:

; error: bad argument type: fixnump: nil


did you copy all brackets from Lee's code?

 

Lee's code with other formatting, copy all code, and try it

 

(initget "45 90 180")
(setq ang (atoi
	    (cond ((getkword "\nEnter Rotation Angle [45/90/180] <45>: "))
		  ("45")
	    )
	  )
)

 

Henrique

EESignature

Message 7 of 9
Lee_Mac
in reply to: JCprog

JCprog wrote:

Thanks for the code Lee but it gives me this error:

; error: bad argument type: fixnump: nil

 

Sorry, but I see nothing in my posted code that would cause that error - please note that the code I have posted is by no means a complete program, but just the snippet relevant to your question.

 

Message 8 of 9
JCprog
in reply to: Lee_Mac

Thanks for the code Lee....I finally got it to work! Smiley Very Happy

Message 9 of 9
Lee_Mac
in reply to: JCprog

JCprog wrote:

Thanks for the code Lee....I finally got it to work! Smiley Very Happy

 

Excellent to hear - you're welcome JCprog Smiley Happy

 

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

Post to forums  

Autodesk Design & Make Report

”Boost