Jump to content

User input: Getpoint OR real at the same time. Its possible?

Recommended Posts

Hi everybody,


First thing I want to apologize if something that I wrote sounds strange. Im spanish and my english is not as good as it should be=P.

Im learling little by little autolisp things, mostly strugling through examples, codes, etc... many of them from this forum so I thank you a lot ^_^.


At this moment I'm developing a routine that breaks/trims walls in order to insert doors or windows, and, after looking for it a few days, I would like to know if there's a way to use a number that users input on the command line (in a getpoint) without getting an error.,... wich is that happends everytime =/.


;; HOLE-O-MaTIC 2000
;;  by Arturo Blanco Ureña. 2013
;; Breaks "walls" in order to insert windows or doors
;; Based initialy on code from Pavel Chour http://klobouk.fsv.cvut.cz/~chour/Lisp/Chapter%206.htm

(defun error1 (errmsg)
  (command "_undo" "_end")
  (setvar "CMDECHO" 1)
  (setvar "OSMODE" osmodevar)
  (setq *error* temperr)
  (prompt "\nAchtung!!! Verboten!!! Error!!!\n")

(defun c:holes(/ );P1a P2a P1 P2 P3 P4 A1 A2)
 (setq osmodevar 	(getvar 'OSMODE)
temperr   	*error*
*error*   	error1
 (if (not ancho) (setq ancho 1.50))
 (setq Tancho (rtos ancho)
P1 "Width"
 (setvar "CMDECHO" 0)
 (command "_undo" "_begin")
 (setvar "osmode" 512)
 ;I'm using this structure in order to go back to the menu so I can change my mind several times.
 ;Don't know if there's a better way =P. 
 (while (= P1 "Width")
  (initget 128)
  (setq P1 (getpoint (strcat "\nSelect Point or [Center/Width]<" Tancho ">:")))
  (cond ((numberp P1)	(setq ancho P1)			;trying to recognice P1 as a number but always goes on error =/
  		(setq Tancho (rtos ancho))
    	 ((= P1 "Width")(setvar "osmode" 35)		
  		(setq ancho (getdist "\nWidth of the Door/window?:"))
			(setq Tancho (rtos ancho))
   );end cond
  );end while
 (cond ((= P1 "Center") (setvar "OSMODE" 518) 		;If the user want to break from the center of the window.
 		(setq P1a (getpoint (strcat "\nSelect center <" Tancho ">:")))
 		(setvar "OSMODE" 128)
		(setq P2a (getpoint P1a "\nSelect the other side of the wall:")
		      A1 (angle P1a P2a)
		      A2 (+ (* pi 1.5) A1)
		      P1 (polar P1a A2 (* ancho 0.5))
		      P3 (polar P1a A2 (* ancho -0.5))
		      P2 (polar P2a A2 (* ancho 0.5))
		      P4 (polar P2a A2 (* ancho -0.5))
 );end cond1
  (T	 (setvar "osmode" 128) 			;if he/she wants to start from one side
	 (setq P2 (getpoint P1 "\nSelect the other side of the wall:"))
	 (setvar "osmode" 512)
  	 (setq	A1 (angle P1 P2)
		A2 (+ (* pi 1.5) A1)
		P3 (polar P1 A2 ancho)
		P4 (polar P2 A2 ancho)
		P1a (polar P1 A2 (* ancho 0.5))
		P2a (polar P2 A2 (* ancho 0.5))
   );end else
);end cond
 (setvar "osmode" 512)
 (command	"_break" P1 P3
           	"_break" P2 P4 
   		"_line" P1 P2 "")
 (setq L1 (entlast))
 (command	"_line" P3 P4 "")
 (setq L2 (entlast))
 ;I add this in order to trim extra lines in the middle of the wall.
 (command "_trim" L1 L2 "" "B" P1a P2a "" "")
 (command "_undo" "_end")
 (setvar "CMDECHO" 1)
 (setvar "OSMODE" osmodevar)
 (setq *error* temperr)


As you see You can enter the "Width" to give it, but I would like to simply write down a number when asking for a point, recognize that is a number and use it as the value of the variant. If a point is entered, then continue normally.


Im a bit shy and its the first time i post a code.:oops: I have used several pieces of code from others to arrange the error handling/undo and its originally based on one tutorial from Pavel Chour, so I dont know if its right that I give permission or not to use it, or even its worth it (the trim still fails and i dont really get why :ouch:) but If anyone want to use it feel free.


Any tips critics and opinions are welcome also :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now