Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Value must be positive and nonzero.

6 REPLIES 6
Reply
Message 1 of 7
andrew.nao
1861 Views, 6 Replies

Value must be positive and nonzero.

im trying to make a item balloon that counts up from the last ballon
starting from 1
however i get this error
Value must be positive and nonzero.

what am i doing wrong?



(defun C:itmbln ( / Scale Radius Po Pe Pm Txt)
(setvar "CMDECHO" 0)
(setq curlayer (getvar "CLAYER"))
(while
(setq Scale (getvar "DIMSCALE")
Radius (* 0.1875 Scale)

Po (getpoint "\nStart of Leader: ")
Pe (getpoint Po "\nEnd of Leader: ")
Pm (polar Pe (angle Po Pe) Radius))

(command "line" Po Pe ^C^C)

(command "circle" Pm Radius)

(Setq Txt "1")
(command "text" "M" Pm 0 txt)
(setq txt (1+ txt))
)

(princ)
) ; end
6 REPLIES 6
Message 2 of 7
EC-CAD
in reply to: andrew.nao

You are trying to 'increment' a string.
(Setq Txt "1"); here Txt becomes 'type' STR, a string
(command "text" "M" Pm 0 txt); this line is OK
To 'increment' that text... after you apply it, do:
(setq Txt (atoi Txt)); make Txt (str) into an integer
(setq txt (1+ txt)); increment the integer
(setq Txt (itoa Txt)); make it a string again for next loop

Bob
Message 3 of 7
andrew.nao
in reply to: andrew.nao

i did that and i got this error
error: bad argument type: numberp: "1"

so i changed some things up and it works the first time but keeps asking me for the next number
so im missing something else

here is the new code

(defun C:itmbln ( / Scale Radius Po Pe Pm Txt)
(setvar "CMDECHO" 0)

(while
(setq Scale (getvar "DIMSCALE")
Radius (* 0.1875 Scale)

Po (getpoint "\nStart of Leader: ")
Pe (getpoint Po "\nEnd of Leader: ")
Pm (polar Pe (angle Po Pe) Radius)
)

(command "line" Po Pe ^C^C)

(command "circle" Pm Radius) ; draw circle

(Setq Txt (getint "\nEnterNumber: "))
(command "text" "M" Pm
(* Scale (getvar "DIMTXT")) 0 (itoa txt))
(setq txt (1+ txt))

)

(princ)
) ; end


sorry i cant get it to show formatted Edited by: andrew.nao on Oct 13, 2008 6:31 PM
Message 4 of 7
Anonymous
in reply to: andrew.nao

I think you may want to format it something like this.

Regards,

Mel

{code:lisp}
(defun C:itmbln ( / Scale Radius Po Pe Pm Txt)
(setvar "CMDECHO" 0)
(initget 7)
(Setq Txt (getint "\nEnter Number: "))
(while (and(setq Po(getpoint "\nStart of Leader: "))
(setq Pe(getpoint Po "\nEnd of Leader: "))
)
(setq Scale (getvar "DIMSCALE")
Radius (* 0.1875 Scale)
Pm (polar Pe (angle Po Pe) Radius)
)
(command "line" Po Pe "")
(command "circle" Pm Radius) ; draw circle
(command "text" "M" Pm (* Scale (getvar "DIMTXT")) 0 (itoa txt))
(setq txt (1+ txt))
)
(princ)
)
{code}
Message 5 of 7
jevers
in reply to: andrew.nao

By the way, Mel, how did you generate that text formatting?
Message 6 of 7
Anonymous
in reply to: andrew.nao


Wrap the code in:

 

{code:lisp

{code}

 

I left off the first closing brace so it displays
in the web forum. (hopefully)

 

Regards,

 

Mel


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
By
the way, Mel, how did you generate that text
formatting?
Message 7 of 7
andrew.nao
in reply to: andrew.nao

thanks mel this did the trick

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost