Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
andrew.nao
Posts: 185
Registered: ‎09-25-2008
Message 1 of 7 (101 Views)

Value must be positive and nonzero.

101 Views, 6 Replies
10-13-2008 11:09 AM
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
Distinguished Contributor
EC-CAD
Posts: 5,929
Registered: ‎12-12-2003
Message 2 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-13-2008 11:20 AM 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
Distinguished Contributor
andrew.nao
Posts: 185
Registered: ‎09-25-2008
Message 3 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-13-2008 11:31 AM 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
*MelFranks
Message 4 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-13-2008 12:35 PM 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}
New Member
jevers
Posts: 2
Registered: ‎09-30-2008
Message 5 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-13-2008 10:34 PM in reply to: andrew.nao
By the way, Mel, how did you generate that text formatting?
*MelFranks
Message 6 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-14-2008 06:35 AM 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?
Distinguished Contributor
andrew.nao
Posts: 185
Registered: ‎09-25-2008
Message 7 of 7 (101 Views)

Re: Value must be positive and nonzero.

10-14-2008 07:46 AM in reply to: andrew.nao
thanks mel this did the trick
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.