legg1979 Posted March 12, 2009 Share Posted March 12, 2009 Hi people, I'm brand new here & am self learning lisp's so i might not be up to any of your level yet. My problem is: I have 2 lisp's that I am trying to join. The 1st lisp is for entering a ceiling text ELLIPSE with height within it. The second lisp is a tag (an arc with a donut on one end). Both these lisps work fine, I am trying to add the tag lisp to the end of the Ellipse lisp, but with a "do you want to add a tag" question. Not sure if you will under stand what i mean. I want the lisp to end up like this..... Start lisp, Enter ceiling height pick point on screen for location of height ellipse THEN a question asking "do you want to add a tag?" If you answer yes the tag lisp will start, if you answer no the lisp will end. Any help would be great thanks. Paul Quote Link to comment Share on other sites More sharing options...
uddfl Posted March 12, 2009 Share Posted March 12, 2009 This would be the most basic way to do it. Add these lines in between the ellipse code and the tag code: (initget "Y N _Yes No") (setq option (getkword "\nDo you want to add a tag? (Yes/No): ")) (if (= option "Yes") (progn (YOUR_TAG_CODE_HERE) ; add tag if yes ) ) Quote Link to comment Share on other sites More sharing options...
legg1979 Posted March 12, 2009 Author Share Posted March 12, 2009 Cant seem to get that working havnt a clue what im doing wrong Quote Link to comment Share on other sites More sharing options...
uddfl Posted March 12, 2009 Share Posted March 12, 2009 You should post your code so that people can have a look and further advise. EDIT: Welcome to the forum! Quote Link to comment Share on other sites More sharing options...
legg1979 Posted March 12, 2009 Author Share Posted March 12, 2009 right this is the height code. ; Elipse with user defined height inserted ; for ceiling and soffit heights ; Error routine (defun errordef (s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setq *errer* olderr) (setvar "CLAYER" lay) (princ) ) (defun c:ctx(/ ht p th se sn ee en e n te tn np) (setq olderr *error* *error* errordef) (setvar "CMDECHO" 0) (setq lay (getvar "CLAYER")) (setq ht (getstring "\nHeight : " 1)) (setq p (getpoint "\nInsertion Point -> ")) (setq th (getvar "TEXTSIZE")) (setq hth (/ th 2)) (command "LAYER" "MA" "LEVEL" "") (setq se (rtos (/ (* th (strlen ht)) 1.7))) (setq sn (rtos (* th 1.2))) (setq ee (strcat "@" se "<0")) (setq en (strcat "@" sn "<90")) (command "ELLIPSE" "c" p ee en) (setq e (car p)) (setq n (cadr p)) (setq te (- e (/ (* (strlen ht) th) 2.1))) (setq tn (- n (/ th 2))) (setq np (list te tn 0)) (command "TEXT" np "" "0" ht) (setvar "CLAYER" lay) ) & this is the tag code. Save modes ;;; (defun MODES (A) (setq MLST ' ()) (repeat (length A) (setq MLST (append MLST (list (list (car A) (getvar (car A)))))) (setq A (cdr A)) ) ); defun modes ;;; ;;; Restore modes ;;; (defun MODER () (repeat (length MLST) (setvar (caar MLST) (cadar MLST) ) (setq MLST (cdr MLST)) );repeat ); defun moder ;;; ;;; ArcDot error handler ;;; (defun AD_ERR (ERRMSG) ; If an error (such as Ctrl-C) occurs while this command is active... (if (and (/= ERRMSG "Function cancelled") (/= ERRMSG "quit / exit abort") ) (princ (strcat "\nError: " ERRMSG)) );if (moder) ; Restore modified modes (setq *error* OLDERR) ; Restore old *error* handler (princ) ); defun ad_err ;;; ;;; Main Program ;;; (defun C:ARCDOT (/ DTDIAM DTRAD PL P2 P3) (setq OLDERR *error* *error* AD_ERR) (modes '("BLIPMODE" "CMDECHO")) (setvar "CMDECHO" 0) (setvar "BLIPMODE" 0) (setq lay (getvar "CLAYER")) (command "LAYER" "MA" "HEIGHT" "") (setq DTDIAM (getvar "textsize")) ; dot diam. = dim. arrow size (setq P1 (getpoint "\nDot location: ") P2 (polar P1 (/ pi 2) (/ DTDIAM 4)) P3 (polar P1 (* pi 1.5) (/ DTDIAM 4)) ) (command "PLINE" P2 "Width" (/ DTDIAM 2) "" ; width = dot diam. / 2 "Arc" "CE" P1 P3 P2 ; semicircle 90->270 & 270->90 "Line" "Width" 0.0 "" P1 "" ; return to p1 ) ; Arc is drawn as a separate non-polyline entity to use the better drawing ; options available with the Arc command. (command "Arc" P1 "E") (prompt "\nEndpoint of arc: ") (command pause "D") (prompt "\nDirection of arc: ") (command pause) ; Join the arc to the dot (setq DTRAD (/ DTDIAM 2) ; +/- offset around dot P2 (list (- (car P1) DTRAD) ; x- offset (- (cadr P1) DTRAD) ; y- offset (- (caddr P1) DTRAD)) ; z- offset P3 (list (+ (car P1) DTRAD) ; x+ offset (+ (cadr P1) DTRAD) ; y+ offset (+ (caddr P1) DTRAD)) ; z+ offset );setq (command "Pedit" "@" "Y" "Width" 0.0 "J" "Window" P2 P3 "" "") (moder) ; Restore modified modes (setq *error* OLDERR) ; Restore old *error* handler (setvar "CLAYER" lay) (princ) ); defun arcdot (defun C:AD () (C:ARCDOT)) ; alias name for function Quote Link to comment Share on other sites More sharing options...
uddfl Posted March 12, 2009 Share Posted March 12, 2009 Well I did have a missing parenthesis in my code's setq. Sorry about that. This seems to work, I called the function "ctxad" (defun c:ctxad () ; ctx + arcdot (c:ctx) (initget "Y N _Yes No") (setq option (getkword "\nDo you want to add a tag (Yes/No): ")) (if (= option "Yes") (c:arcdot) ; add tag if yes ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Se7en Posted March 12, 2009 Share Posted March 12, 2009 Allow me to introduce you to the: R. Robert Bell ``Default'' method Here is his original text (this took me a long time to dig up): *** Has it ever bugged you trying to handle a default option with (getkword)? The usual method I've seen is to get the input, and then handle the user's selection of the default, resetting the variable if need be. Here is an example of the "traditional" method: ,----[ CODE ]- | | (progn | (initget 0 "Length Width Depth Time") | (setq Inp (getkword "\nSpecify a dimension [Length/Width/Depth/Time] : ")) | (setq Inp (if Inp Inp "Time")) | ) | `---- Consider the alternative below however. ,----[ CODE ]- | | (initget 0 "Length Width Depth Time") | (setq Inp | (cond | ( (getkword "\nSpecify a dimension [Length/Width/Depth/Time] : ") ) | ("Time")) ) | `---- Quote Link to comment Share on other sites More sharing options...
wizman Posted March 12, 2009 Share Posted March 12, 2009 while we're on this topic, just an addition to this Yes/No function, (if express is installed). (SETQ MYANSWER (ACET-UI-MESSAGE "PICK YES OR NO" "MY CAPTION" ACET:YESNO)) 6 = Yes 7 = No but not recommended for starters, just keep it.....'-) Quote Link to comment Share on other sites More sharing options...
Se7en Posted March 12, 2009 Share Posted March 12, 2009 ACET-* functions are not recommended at all. ~ ...Seriously. Quote Link to comment Share on other sites More sharing options...
wizman Posted March 12, 2009 Share Posted March 12, 2009 I agree se7en, unless one is in a quick hurry(joke). BTW, Nice of you to hang here. We'll surely be learning a lot from you....'-) Quote Link to comment Share on other sites More sharing options...
legg1979 Posted March 12, 2009 Author Share Posted March 12, 2009 That works just how i wanted thanks very much. Just added a few little tweeks to the OSMODE & now its perfect Thanks again guys & girls Quote Link to comment Share on other sites More sharing options...
Se7en Posted March 12, 2009 Share Posted March 12, 2009 > I agree ... Good! Now that that's settled let's not mention them again. ~ > We'll surely be learning a lot from you.... Learn from me? *7: looks around* ...I'm still learning myself. But seriously though, Lisp is my hobby. I love the AutoLisp language; i love its simplicity. Even when im using other languages i think in AutoLisp. *lol* > Nice of you to hang here... No problem, im always up for a good challenge. *lol* Just dont take my short remarks to heart, i dont have a lot of time to write ``flowers'' and ``sunshine''; i dont mean any harm, im really a very nice guy. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.