teknomatika Posted June 30, 2011 Share Posted June 30, 2011 I need your help: I'm developing a simple routine that allows you to enter a real number and this note is written in the Z coordinate, corresponding to the number itself. What I want is that from the first cycle if the input value is null, it is assumed the number of the previous cycle. The strange thing is that I have taken with the solution reached in routine, It worked but not now. Strange. The solution should be simple but I was blocked and I am not able to resolve the problem. (defun c:nrz (/ gnr gpt rep xx yy zz zzfinal) (setq gnr (getreal "\nNumber:")) (if (= gnr nil) (setq gnr rep) ) (setq gpt (getpoint "\nPick a point:")) (setq xx (car gpt)) (setq yy (cadr gpt)) (setq zz (caddr gpt)) (setq zz gnr) (setq zzfinal (list xx yy zz)) (command ".text" zzfinal 0.20 0 (rtos gnr 2 2)) (setq rep gnr) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 30, 2011 Share Posted June 30, 2011 Just give a real number to the variable rep at the top before the if function . e.g (setq rep 12.0) And one more thing , I guess you should replace the (rtos gnr 2 2) to be (rtos zzfinal 2 2 ) to contain all number since you supported them with numbers . Tharwat Quote Link to comment Share on other sites More sharing options...
teknomatika Posted June 30, 2011 Author Share Posted June 30, 2011 Just give a real number to the variable rep at the top before the if function . e.g (setq rep 12.0) And one more thing , I guess you should replace the (rtos gnr 2 2) to be (rtos zzfinal 2 2 ) to contain all number since you supported them with numbers . Tharwat I appreciate the suggestion. As for the whole could be coordinated, but just in case I intend to write the value Z. As for the value to assign to the variable (setq rep) is not what I want. I want the first entry after the nil value assumes the previous value. This will allow to continue writing the same number repeatedly until you want to change. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 30, 2011 Share Posted June 30, 2011 (edited) Consider this code: (defun c:nrz ( / pt ) (if (and (setq *gnr* (cond ( (getreal (strcat "\nNumber" (if *gnr* (strcat " <" (rtos *gnr* 2 2) ">: ") ": ") ) ) ) ( *gnr* ) ) ) (setq pt (getpoint "\nPick a Point: ")) (setq pt (trans pt 1 0)) ) (entmakex (list (cons 0 "TEXT") (list 10 (car pt) (cadr pt) *gnr*) (list 11 (car pt) (cadr pt) *gnr*) (cons 40 0.2) (cons 1 (rtos *gnr* 2 2)) (cons 7 (getvar 'TEXTSTYLE)) (cons 72 1) (cons 73 2) ) ) ) (princ) ) Perhaps this tutorial will also help. Edited June 30, 2011 by Lee Mac Added link to tutorial Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 30, 2011 Share Posted June 30, 2011 This may close .. (defun c:nrz (/ z p) (setq z (getreal "\n Enter number <1.0> :")) (setq p (getpoint "\n Text location :")) (entmake (list '(0 . "TEXT") '(100 . "AcDbEntity") '(100 . "AcDbText") (cons 10 (trans p 1 0)) (cons 40 (getvar 'textsize)) (cons 50 0.0) (cons 1 (if (not z) (setq z "1.00") (rtos z 2 2) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
teknomatika Posted July 1, 2011 Author Share Posted July 1, 2011 Lee Mac, tanks! Excellent. This is exactly what I wanted. Who is good is good. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 1, 2011 Share Posted July 1, 2011 Lee Mac, tanks!Excellent. This is exactly what I wanted. Who is good is good. You're welcome, I hope it helps with your understanding 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.