Author Topic: Automatic block numbering...is this possible?  (Read 2899 times)

0 Members and 1 Guest are viewing this topic.

CECE_CAD

  • Guest
Automatic block numbering...is this possible?
« on: January 15, 2007, 03:26:51 PM »
Ok, I have a block that is used as a tag and it’s attributed.  This block could be used about 130 times in one drawing.  I want to make it were the block knows to automatically change to the next number if it’s copied or inserted again.  Is this lisp possible? I have tried number count but its not want I want.

The block does not have to be attributed, it could be a field or what ever works the best..

ELOQUINTET

  • Guest
Re: Automatic block numbering...is this possible?
« Reply #1 on: January 15, 2007, 06:06:29 PM »
i do wiring as part of my job and we have to number the motors so we use this blocks that inserts a block and increment it's attribute by a specified value for each insert. It sounds like it could be tweak slightly to suit your needs. enjoy

Code: [Select]
(defun c:mi1 ( / n inc a)
 (setq cme (getvar "CMDECHO"))
 (setq att (getvar "ATTDIA"))
   (setvar "CMDECHO" 0)
   (setvar "ATTDIA" 0)
    (setq n (getint "\nLast inserted motor number: ")
          inc (getint "\nEnter incriment value for motor numbering: "))
       (while (not *Cancel*)
       (setq a (getstring nil "\nBLOCK NAME: ")
       )
       (command "insert" a pause "1" "" 0 (itoa (+ inc n)))
       (setq n (+ inc n))
      )
  (setvar "CMDECHO" cme)
  (setvar "ATTDIA" att)
)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Automatic block numbering...is this possible?
« Reply #2 on: January 15, 2007, 06:10:30 PM »
An attribute would work fine, but you would need an event reactor to fire whenever the block was inserted and whenever it was copied.
If I were to design one, I would do it in VBA rather than lisp as there are reported problems with persistent lisp reactors.

So, lets start with ...

Upon the insert command, and the target block is the one being inserted find an xrecord in the drawing corresponding to your data, if it doesn't exist, create one and put the first number in it or if it exists copy the number to the block and increment the xrecord. If you copy an object, if it is the target block, then find the xrecord (at this point it should exist) and then copy the number to the copied block and update the xrecord.

Sorry I can't give any more advice at the moment as I am tied up on other items at the moment.

Dan's program will only work while you are currently working on the drawing. Any subsequent work would not be what you are looking for .. I don't think so anyway ...
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
Re: Automatic block numbering...is this possible?
« Reply #3 on: January 15, 2007, 08:44:52 PM »
Another approach using a dedicated routine to insert the block might work like this:

Code: [Select]
User runs the routine
Get all target blocks in the dwg

If none ask the user for starting value
Else
  Get all the target attributes values
  Find the max value
  Increment the value by one

Get the user insert point
Create the insert at that point
Update the attribute
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Automatic block numbering...is this possible?
« Reply #4 on: January 15, 2007, 08:56:19 PM »
.. plus possibly test for any 'gaps' in the number sequence to fill. I have questions about the efficacy of using Xrecords or a dictionary because of the possibility of a user simply editing an attribute while any reactor in not active.  You could also consider some form of automated audit procedure .
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.

VVA

  • Newt
  • Posts: 166
Re: Automatic block numbering...is this possible?
« Reply #5 on: January 16, 2007, 02:22:57 AM »
I use this {Smirnoff} and ASMI rountines
Num - Insert text with increment value
Renum - Renumbering text in DIMENSION, TEXT, MTEXT, ATTRIB, ATTDEF, ACAD_TABLE
TTC - Text to Text copy. Copy text from DIMENSION, TEXT, MTEXT, ATTRIB, ATTDEF, ACAD_TABLE to one
Apnum - for numbering by blocks with single attribute
The command RENUM can change numbering in DIMENSION, TEXT, MTEXT, ATTRIB in blocks, ATTDEF, ACAD_TABLE.
Choosing the block, it is necessary to specify on attribute.


Patrick_35

  • Guest
Re: Automatic block numbering...is this possible?
« Reply #6 on: January 16, 2007, 03:22:56 AM »
Hello
I made this lisp at the French base that I endeavoured to translate.
It makes it possible to bind attributes so that their values are incremented, that is to say identical or makes a total
It functions on the principle of the reactors in nonpersistent, which want to say that it should be charged with each opening of a drawing.
To make it function, it is enough to link two attributes, and the remainder is done all alone (to copy, erase, etc…)

@+

ELOQUINTET

  • Guest
Re: Automatic block numbering...is this possible?
« Reply #7 on: January 16, 2007, 09:10:25 AM »
yes my routine is not as automated but then again we do most of our numbering in one shot but it does ask for a starting number so you could stop midway then resume later. we also have a routine to increment the attributes by a specified number iin case a motor is added at the beginning for instance. we also have a routine that allows you to number the attributes in the order which they were selected. If you want I can share these but sounds like you are looking for something more automated. I want to check out yours Patrick as I'm not sure exactly what it does.

CECE_CAD

  • Guest
Re: Automatic block numbering...is this possible?
« Reply #8 on: January 16, 2007, 02:35:54 PM »
Wow! You guys are good, I didn't think it would be this intense.  The mechanical group has parts that they number and sometimes they do a break down of each part, they could have up to 100+ parts on a sheet.  They hate having to edit all the numbers in the blocks.  What I was thinking of doing is using one of the codes you have provided with my block, but I will creat a new name for it so that its not always used because its only needed for numbering.  To do this I would have to put the name of my block in one the routines...?  Atleast thats what I believe I would have to do to make it work.  I don't really see how else to use it. 

I have not checked them out yet but I think I should be able to use one of them.  Thanks everyone! I will let you know which one does the trick.  I appreciate the help.


GDF

  • Water Moccasin
  • Posts: 2081
Re: Automatic block numbering...is this possible?
« Reply #9 on: January 16, 2007, 05:07:50 PM »
Hello
I made this lisp at the French base that I endeavoured to translate.
It makes it possible to bind attributes so that their values are incremented, that is to say identical or makes a total
It functions on the principle of the reactors in nonpersistent, which want to say that it should be charged with each opening of a drawing.
To make it function, it is enough to link two attributes, and the remainder is done all alone (to copy, erase, etc…)

@+

Nice routine...Pretty slick!

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64