Author Topic: Renumerating  (Read 17197 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: 16899
  • 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?

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
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)
Member location map - Add yourself

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: 16899
  • 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

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
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)
Member location map - Add yourself

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.

deegeecees

  • Guest
Renumerating
« Reply #15 on: January 05, 2004, 02:35:02 PM »
So, my spelling aint so good, umm, yes, what is your operating status Mr. Water Bear?

AutoCAD version?
Operating System?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Renumerating
« Reply #16 on: January 05, 2004, 02:39:05 PM »
Perhaps something like this would suit ?

kwb

Code: [Select]

(defun nextductid (/ returnvalue)
  (or #cnt (setq #cnt (getcfg "appdata/MySTUFF/LastDuctID")))
  (or (and #cnt (/= 0 (strlen #cnt)))
      (setq returnvalue (getint "No Duct Number has been saved. Enter New Number :"
                        )
            returnvalue (if (= returnvalue "")
                          000
                          (1- returnvalue)
                        )
      )
     
  )
  (if (numberp returnvalue)
    (setq #cnt (itoa(1+ returnvalue)))
    (setq #cnt (itoa(1+ (atoi #cnt))))  
  )    
  (setcfg "appdata/MySTUFF/LastDuctID" #cnt)
  #cnt
)

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #17 on: January 05, 2004, 02:42:24 PM »
Kerry, I actually had thought of using that scenario, but if there are multiple drawings, the duct number would be incorrect in a different drawing. I suggest using the system variable USERI1 to store the number since it is an integer and is stored in the drawing when it is saved.
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

deegeecees

  • Guest
Renumerating
« Reply #18 on: January 05, 2004, 02:43:47 PM »
Oh, sure just give him the whole farm. How will people ever learn to be responsible Lispers if they never learn on their own?

Keb, if another routine uses the USER??? variables when a drawing is opened, he's not going to aquire the correct info from it. The CORRECT way would be the sort through method.

Water Bear

  • Guest
kudos...
« Reply #19 on: January 05, 2004, 02:43:54 PM »
DGCs..thanx, let me work on the ssget "x"
p.s. I noticed right away KEB wuz pulling a chain...hater!

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #20 on: January 05, 2004, 02:46:49 PM »
Huh????I aint pullin no ones chain....I aint got no hands....If'n ya don't want to just replace yer cnt code with my edited one that's fine cuz I just like to code....

an wazzup with hater????
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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Renumerating
« Reply #21 on: January 05, 2004, 02:47:16 PM »
Perhaps this then

(setcfg (strcat "appdata/MySTUFF/" (getvar "dwgname") "/LastDuctID") "123")
(getcfg (strcat "appdata/MySTUFF/" (getvar "dwgname") "/LastDuctID"))

< added >
Keith ... its just that I loath the "USERxxx" vars :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

daron

  • Guest
Renumerating
« Reply #22 on: January 05, 2004, 02:52:05 PM »
Quote from: KEB
Huh????I aint pullin no ones chain....I aint got no hands....If'n ya don't want to just replace yer cnt code with my edited one that's fine cuz I just like to code....

an wazzup with hater????


I was wondering the same thing. Guy don't know what he's talking about, I think.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #23 on: January 05, 2004, 03:19:18 PM »
Ok, Kerry ... just being the devils advocate for a minute.. what happens when he has edited like a thousand drawings....the acad.cfg gets HUGE, plus the drawing cannot be edited across machines effectively...

If you don't like USERxx variables that is ok.. I was simply trying to offer the simplest solution to the problem..

But...
We can still have an internal count (internal to the drawing) that is editable by the program across multiple edits and on different machines at the same time...

Code: [Select]

(defun CNT ()
  (vl-load-com) ; per the Daron Act
  (if #CNT
     nil
     (if (not(setq #CNT (vlax-ldata-get "DuctCount" "CNT")))
         (setq #CNT 0)
     )
  )
  (setq #CNT (1+ #CNT))
  (vlax-ldata-put "DuctCount" "CNT" #CNT)
  (princ)
  )


Now how is that.....totally portable, usable on R2000+, no external files and simple.
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
my bad..
« Reply #24 on: January 05, 2004, 03:25:03 PM »
Sorry if I step on any toes..I thought someone was INTENTIONALLY misdirecting me because of inconstistent "USERI1" variables...but the post has since been corrected..my bad, I should have known it was an innocent typo! my apologies to KEB

DGCs:2k4 XP

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Renumerating
« Reply #25 on: January 05, 2004, 03:31:01 PM »
Keith :: Yep that works cool.

what's that expression about  lots of ways to pluck a duck :D

An effective solution depends on the project requirements, which we dont know of course.

Personally I would use attributed blocks, then a search is easier, and so is renumbering if you have to.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Water Bear

  • Guest
humm...
« Reply #26 on: January 05, 2004, 03:54:32 PM »
KerryB
That sounds like an interesting alternative (attributes) how would I setup to re-number? What function could I use?

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Renumerating
« Reply #27 on: January 05, 2004, 04:03:53 PM »
I like ldata. (I always forget about it too!) I like the idea of an external file, but thats cool. whatever works.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #28 on: January 05, 2004, 04:03:56 PM »
Quote
how would I setup to re-number? What function could I use?

WB, you would need to use attributed blocks for your numbering scheme, even if it is simply a single attribute with no other objects. You could then filter for the block name and each one would have a unique number. Once the selection of the blocks is completed, you would simply need to use other routines available from this site to update and/or change the numbering.
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

deegeecees

  • Guest
Another Duck
« Reply #29 on: January 05, 2004, 04:31:56 PM »
How about using xdata. Attach xtended entity data to the entities in question. If they are text entities all the better, just find em and manipulate em.

Quack.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #30 on: January 05, 2004, 04:57:17 PM »
Xdata can be difficult to master, I seldom use it, but to each 'is own
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Renumerating
« Reply #31 on: January 05, 2004, 07:05:50 PM »
This area is new to me, but could you use a block to store the last entered number
leaving all labels as text. I suppose the block could be on a Non-plotting layer
or hidden somehow?

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Renumerating
« Reply #32 on: January 05, 2004, 07:11:12 PM »
> or hidden somehow?
How about
vlax-put-property obj 'Visible :vlax-false
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #33 on: January 05, 2004, 07:19:42 PM »
There you go... another ingenious way to solve a problem....insert a single block with a single attribute in the drawing, make it invisible, then simply search for and extract that and update that block data as needed.

Well, I know there was a more than one way to skin a cat....fish that is...
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

SMadsen

  • Guest
Renumerating
« Reply #34 on: January 06, 2004, 08:38:48 AM »
Quote from: deegeecees
Use  use ssget "x" function to collect all text objects on the layer, then iterate through them, creating a list.

I think deegeecees has the only worth while solution to this problem. Imagine someone missing to order 50 duct pieces just because someone forgot to run a lisp routine? Not good.

Run through all the existing numbers, decide which is the most recent and start counting from there on. Whether it is text, mtext, attribute info or whatever holding the numbers. Reorganize the drawings if needed - put numbers on unique layers, in unique attributes or attach a signature as xdata saying it is a duct number. Doesn't matter, but don't save the last count anywhere! Get the last count fresh from the bakery each time you need to add a count.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #35 on: January 06, 2004, 08:52:55 AM »
Stig, the original request was that the lisp that WB had would not retrieve the last number used, we were simply trying to fix an otherwise fine lisp by having it retrieve and store the last number used.

There are merits to any system used, but no matter how you look at it, somewhere someone MUST run a lisp, vba or macro and since the lisp is what will number the duct pieces, the user cannot simply "forget" to run it, to do so would be to "forget" to do their job in the first place.

 I know there were at least 5 good solutions to this scenario the job of deciding which to use is up to WB, that is why we have a forum to get everyones input.
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

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Renumerating
« Reply #36 on: January 06, 2004, 09:29:07 AM »
I think Stig has a point.

Also: What are you gonna do if someone decides to copy a section of duct with hidden xdata? They run the app and the app starts off with a huge number. I am begining to think that saving the info anywhere but in the entity itself is a bad thing. (I can already see quite a bit of info being stored in that object.)

...This had better get drawn out, cuase this could get messy!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Renumerating
« Reply #37 on: January 06, 2004, 09:30:46 AM »
Quote from: KEB
Stig, the original request was that the lisp that WB had would not retrieve the last number used.

Keith, you're correct. And I say, retrieve the last number, not by saving it, but by counting to it.

Quote from: KEB
.. somewhere someone MUST run a lisp, vba or macro and since the lisp is what will number the duct pieces, the user cannot simply "forget" to run it, to do so would be to "forget" to do their job in the first place.

True, but consider this:

1. Get last count from saved static data
2. Increment number
3. Click at duct piece to add number
4. Go to 2. until done
5. Save last count as static data

Splendid. Now do as users always do: hit Escape at no. 3. Replace no. 4 with 5? Hit escape somewhere else.
Use USERxx or LData? Load another app that overwrites it. Use Dicts? Lost if wblocked. Use XData? Hit Esc at the wrong place and it's out of sync. Use external file? Out of sync on different stations. Just too risky to save a single number somewhere if it can be retrieved on the fly. One could even put a verifier into the code to report errors in existing sequences.

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Renumerating
« Reply #38 on: January 06, 2004, 09:33:06 AM »
count each time?! ...Yeah i see your point Stig.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Renumerating
« Reply #39 on: January 06, 2004, 09:41:43 AM »
Yeah well, count each time you need a number to count from, i.e. each time the routine is run  :)

daron

  • Guest
Renumerating
« Reply #40 on: January 06, 2004, 09:44:16 AM »
Sure, considering user variables can be changed by anybody at any time.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Renumerating
« Reply #41 on: January 06, 2004, 09:47:34 AM »
Stig...point taken, and it is a very valid point, WB will simply have to ensure that a standard is adhered to when applying numbers to ducts. If a routine is going to retrieve all of the duct numbers, the duct numbers must be identified by either xdata, a special layer, textstyle, blockname or other uniquely identifiable trait that can be filtered for. This is where a drawing standard will come in... I think we all understand the importance of standards...Now it is simply a matter of getting the information from WB as to what he would like to do.
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Renumerating
« Reply #42 on: January 06, 2004, 09:12:27 PM »
While your at it how about

Report any missing numbers

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.