Jump to content

Number Increment...


jasonb_880

Recommended Posts

Hey guys, looking for some help here,

i've found various lisp files for incrementing numbers but none that do multiple numbers in a single text line i.e. 01/01/01-02 then the next being 01/01/03-04 then 01/01/05-06 and so on...

 

Anyone got any ideas??

 

Cheers,

 

Jason

Link to comment
Share on other sites

Open one of them in "_vlide" go to help to learn what does what and you'll be able to figure out the rest. I did it the same way.

 

DIY is the best way to learn imo...

 

And if you need more guidance see here:

 

 

http://www.cadtutor.net/forum/showthread.php?t=38760

 

http://www.cadtutor.net/forum/showthread.php?t=38734

 

http://www.afralisp.net/

 

http://www.jefferypsanders.com/autolisptut.html

 

http://ronleigh.info/autolisp/index.htm

 

http://midpointcad.com/au/docs/lakose_The_Visual_LISP_Developers_Bible.pdf

Link to comment
Share on other sites

hey, i've managed to get it to the stage it asks for the 2nd number but it only inserts and increments the 1st number...

 

 

(defun c:dinc (/ p n ni pref suff nns ntx ntxx oecho osn ds th txt)
(setq oecho (getvar "cmdecho")
osn (getvar "osmode")
)
(if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
(setq th (getvar "dimtxt"))
(setq txt (* th ds))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(if nn
(setq nn (fix nn))
(setq nn 1)
)
(if (= nn 0)(setq nn 1))
(princ "\n Increment numbers by < ")
(princ nn)
(princ " >? : ")
(setq ni (getint))
(if (= ni nil)
(setq ni nn)
(setq nn ni)
)
(if np
(setq np (fix np))
(setq np nn)
)
(princ "\n Start or continue with number < ")
(princ np)
(princ " >? : ")
(setq n (getint))
(if (= n nil)
(setq n np)
(setq np n)
)
(setq nns (itoa n))
(princ "\n Prefix text < ")
(princ pre)
(princ " >? or <.> for none: ")
(setq pref (getstring t))
(if (= pref ".")
(progn
(setq pre nil)
(setq pref nil)
)
(progn
(if (= pref "")
(setq pref pre)
(setq pre pref)
)
(if pref
(setq ntx (strcat pref nns))
)
)
)
(princ "\n Suffix text < ")
(princ suf)
(princ " >- or <.> for none: ")
(setq suff (getstring t))
(if (= suff ".")
(progn
(setq suf nil)
(setq suff nil)
)
(progn
(if (= suff "")
(setq suff suf)
(setq suf suff)
)
(if suff
(if pref
(setq ntxx (strcat pref nns suff))
(setq ntxx (strcat nns suff))
)
)
)
)
(if (= nn 0)(setq nn 1))
(princ "\n Increment 2nd number by < ")
(princ nn)
(princ " >? : ")
(setq ni (getint))
(if (= ni nil)
(setq ni nn)
(setq nn ni)
)
(if np
(setq np (fix np))
(setq np nn)
)
(princ "\n 2nd number < ")
(princ np)
(princ " >? : ")
(setq n (getint))
(if (= n nil)
(setq n np)
(setq np n)
)
(setq p (getpoint "\n Insert: "))
(setq oecho (getvar "cmdecho"))
(while p
(if suff
;(command "text" "j" "mc" p "" "" ntxx)
(entmake (list (cons 0 "TEXT")
(cons 10 p)
(cons 11 p)
(cons 1 ntxx) ; actual text
(cons 7 (getvar "TEXTSTYLE"))
(cons 40 txt)
(cons 72 4)
)
)
(if pref
;(command "text" "j" "mc" p "" "" ntx)
(entmake (list (cons 0 "TEXT") 
(cons 10 p) 
(cons 11 p) 
(cons 1 ntx); actual text
(cons 7 (getvar "TEXTSTYLE"))
(cons 40 txt)
(cons 72 4)
)
)
;(command "text" "j" "mc" p "" "" n)
(entmake (list (cons 0 "TEXT") 
(cons 10 p) 
(cons 11 p) 
(cons 1 n); actual text
(cons 7 (getvar "TEXTSTYLE"))
(cons 40 txt)
(cons 72 4)
)
)
)
)
(setq p (getpoint "\n Next number location: ")
n (+ ni n)
nns (itoa n)
np n
)

(if suff
(if pref
(setq ntxx (strcat pref nns suff))
(setq ntxx (strcat nns suff))
)
)
(if pref
(if suff
(setq ntxx (strcat pref nns suff))
(setq ntx (strcat pref nns))
)
)
)
(setvar "cmdecho" oecho)
(setvar "osmode" osn)
(princ)
)
(princ "\n Type > DINC < to insert text with ascending integers.")

 

not sure what to do next??

 

Cheers

Link to comment
Share on other sites

Because this is an extract from the routine I wrote a few years back, I am willing to help you to modify it. I will not do it for you though.

 

How much time you have for this? I am leaving now and will be gone for about a week.

 

If someone else wants to jump in, by all means.

Link to comment
Share on other sites

My code asks user for increment number, starting number, prefix and suffix. What you need (if I understand it well [01/01/03-04]) is first starting number(fsn), second starting number (ssn), first increment number (fn), second increment number (sn), first text string (fts) and second text string (sts) in order of fts-fsn-sts-ssn, where fsn and ssn will be updated with each round in 'while' loop by fn and sn respectively. That means that you will have to put in all these user prompts and then assemble the user inputs in correct order and syntax before the "entmake" function can be executed.

What you just did is you copied part of the code, overwrote the prompt string and left the variables as they are. That way you are overwriting the variables "ni", "nn", "n" and "np" (in the code), which were set by user to some values just prior to these added prompts. You have to asign new variables to "ssn" and "sn" to avoid this conflict.

 

If nobody else jumps in while I am gone, read a lot in help files and in the links Lee Mac provided for you and we will continue when I am back.

Link to comment
Share on other sites

managed to get it sorted thanks, kinda understand how it all works now thanks a lot!

 

Cheers

 

Hallo

 

Würdest du den Code hier reinstellen wollen, sowas könnte ich auch gebrauchen.

Danke

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