Author Topic: Renumerating  (Read 12239 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
Renumerating
« on: January 05, 2004, 01:23:25 PM »
I'm numbering duct pieces on a drawing, but when I resume the drawing my lisp function begins counting all over (repeated numbers). Can anyone tell me how I can retrieve the last number used, and continue incrementing by one?

daron

  • Guest
Renumerating
« Reply #1 on: January 05, 2004, 01:24:47 PM »
You might start by showing us the lisp routine you're using.

deegeecees

  • Guest
Renumerating
« Reply #2 on: January 05, 2004, 01:27:01 PM »
Quote from: Daron
You might start by showing us the lisp routine you're using.


Yup.

Water Bear

  • Guest
here it is..
« Reply #3 on: January 05, 2004, 01:43:50 PM »
Code: [Select]
(defun CNT ()
;;;need to search drawing for highest number and set to #CNT

;;;I put this in to keep from crashing on undefined variable
  (if #CNT
    nil
    (setq #CNT 0)
    )
  (setq #CNT (1+ #CNT))

  (princ)
  )
(princ)

deegeecees

  • Guest
Renumerating
« Reply #4 on: January 05, 2004, 01:53:44 PM »
Ok WATER BEAR, when exiting a drawing, all variables that have been assigned are gone. When you load the drawing and try and find the #CNT they are not there. Am I going in the right direction for you? If not, maybe you should post ALL the code.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16867
  • Superior Stupidity at its best
Renumerating
« Reply #5 on: January 05, 2004, 02:10:44 PM »
Try this....
Code: [Select]

(defun CNT ()
  (if #CNT
     nil
     (setq #CNT (getvar "USERI1"))
  )
  (setq #CNT (1+ #CNT))
  (setvar "USERI1" #CNT)
  (princ)
  )


Problem solved....
Cool huh
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Water Bear

  • Guest
bloodhound!
« Reply #6 on: January 05, 2004, 02:12:27 PM »
DGC..you've got it.
The only reason that I didn't post all the code is because I've separated it into four files which I load as a project..and it probably wouldn't make sense without showing the utilities,error traps and I/O routines.
what I need to do is re-establish the last number, probably using tblsearch..but I don't know how to collect all text objects on layer "pc numbers" then find the highest value.

deegeecees

  • Guest
Renumerating
« Reply #7 on: January 05, 2004, 02:14:36 PM »
Check yer fire, check yer fire!

You've got a variable conflict here.

USERI1 or USERR1?

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9673
Re: bloodhound!
« Reply #8 on: January 05, 2004, 02:18:50 PM »
Quote from: Water Bear
what I need to do is re-establish the last number, probably using tblsearch..but I don't know how to collect all text objects on layer "pc numbers" then find the highest value.
Storing the number in a seperate file out of the question?
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

deegeecees

  • Guest
Renumerating
« Reply #9 on: January 05, 2004, 02:18:55 PM »
Use  use ssget "x" function to collect all text objects on the layer, then iterate through them, creating a list. Then use the LAST function to find the highest value. I'm not going to write this for you, you'll have to do it yourself. I will help if you should so ask me for it nicely.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16867
  • Superior Stupidity at its best
Renumerating
« Reply #10 on: January 05, 2004, 02:19:39 PM »
Where......:P
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9673
Renumerating
« Reply #11 on: January 05, 2004, 02:21:54 PM »
What's the text? Is it all going to be a number or is there going to be some text included.
like: Type 'A' 123
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

deegeecees

  • Guest
Renumerating
« Reply #12 on: January 05, 2004, 02:29:24 PM »
OK, ok I'll help.

I use this for REVISION TRACKING...

(setq lastrev (acad_strlsort (list isrev3-1 isrev7 isrev10 isrev13)))
   (setq lastrev (last lastrev))
   (setq lastrevdate
                (cond
      ((= lastrev isrev3-1) isrev5-2)
      ((= lastrev isrev7) isrev6-2)
      ((= lastrev isrev10) isrev7-2)
      ((= lastrev isrev13) isrev8-2)
   )
   )

keep in mind that I set up the values for isrev?-? ahead of time.

daron

  • Guest
Renumerating
« Reply #13 on: January 05, 2004, 02:29:38 PM »
Uhh, you might also want to mention what version of acad you're using as anything pre-2000 won't allow things like vl-sort.

deegeecees

  • Guest
Renumerating
« Reply #14 on: January 05, 2004, 02:31:08 PM »
The acad_strlsort function is alphnumeric, alieviating the need to pick apart the string for its numeric content.