Jump to content

write numbers in the z coordinate


teknomatika

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Lee Mac
Added link to tutorial
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...