Jump to content

Recommended Posts

Posted

Can you tell me why variables D:number will not hold the value when you enter return.

 
(if D:number
   (setq dia (getreal (strcat "\nEnter Nominal diameter <"(rtos D:number)">: ")))
   (setq dia (getreal "\nEnter Nominal diameter: "))
 )
 (if (/= dia "")
   (setq D:number dia)
 )

I've got a message that said

Error: Bad argument type: numberp: nil

 

Because of numberp my guess is the rtos. But how can I correct this?

 

Thanks.

Posted

When you press enter, DIA is nil not an empty string "".

 

try

 

(if (null dia)

(setq D:number dia)

)

 

 

Also, is d:number a global or local variable?

Posted

It is a local variable.

 

I'll try your suggestion. Post later.

 

Thanks

Posted

Suggestion does not work.

 

BTW my fault, d:number should be global and dia local.

Posted

The problem is in your if statement see below...

 

(defun c:test  (  /  dia )
      
(if D:number
   (setq dia (getreal (strcat "\nEnter Nominal diameter <"(rtos D:number)">: ")))

   (setq dia (getreal "\nEnter Nominal diameter: "))
 )
 
 (if dia
    (setq D:number dia)
 )
 )

 

 

You want to change the value of d:number if DIA has a value (non-nil).

Posted

I believe this contains what you are after :P

 


(defun c:tktag2set (/ tsize tcircr)
   (if    (not (getenv "tag:tsize"))
       (setenv "tag:tsize" (rtos (getvar "TEXTSIZE")))
   ) ; end if
   (if     (not (getenv "tag:tcircr"))
       (setenv "tag:tcircr" "4.2")
   ) ; end if
   (princ
       (strcat    "\nCurrent Settings:"
           "\n\tText Height: "
           (getenv "tag:tsize")
           ",\tText Circle Radius @ 1:1: "
           (getenv "tag:tcircr")
       ) ; end strcat
   ) ; end princ
   (if    (setq tsize (getreal (strcat
                   "\nSpecify Text Height <"
                   (getenv "tag:tsize")
                   ">: ")))
       (setenv "tag:tsize" (rtos tsize))
   ) ; end if
   (if    (setq tcircr (getreal (strcat
                   "\nSpecify Text Circle Radius @ 1:1 <"
                   (getenv "tag:tcircr")
                   ">: ")))
       (setenv "tag:tcircr" (rtos tcircr))
   ) ; end if
   (princ "\nBase Variables Set.")
   (princ)
) ; end program
   

Posted

For example:

 

(defun c:test (/ dia)
   (or (getenv "D:number") (setenv "D:number" "5"))
   (if (setq dia (getreal (strcat "\nEnter Nominal Diameter <" (getenv "D:number") ">: ")))
       (setenv "D:number" (rtos dia))
   ) ; end if
   (alert (strcat (getenv "D:number") " is the value of the global Variable."))
   (princ)
)

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