Author Topic: Inserting blocks with Tablesearch??  (Read 4137 times)

0 Members and 1 Guest are viewing this topic.

rude dog

  • Guest
Inserting blocks with Tablesearch??
« on: August 11, 2004, 09:57:34 PM »
Is there a way To reinsert blocks that already exists in the drawing by utilizing the tablesearch and tablenext function?...Does this make for a smaller drawing?....and if it is possible can anyone one point me in the direction of a tutorial......
Thank ya

JohnK

  • Administrator
  • Seagull
  • Posts: 10633
Inserting blocks with Tablesearch??
« Reply #1 on: August 11, 2004, 10:17:47 PM »
Not that i know of. Heres my understanding: the drawing has a Database (Which "tblsearch" queries). Inserting a block will increase the size of a drawing by a factor of 'n', no-matter if its definition exists in the Database or not.

Inserting a block thru code is the same way AutoCAD does it. If the definition dosent exsit in the database then check the paths, if you cant find it in any of the paths, then ask where it is.

Did that make any sence? LoL
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Inserting blocks with Tablesearch??
« Reply #2 on: August 11, 2004, 10:19:05 PM »
I must be not quite understanding what you are asking.

For a block to be inserted to a drawing, it MUST first be defined in the Block Table. Once it is defined (which INSERT does if you specify file from outside the drawing), ALL insertions are just references back to the definition in the Table.

Searching the block table with tblsearch, and tblnext will ONLY tell you if a specific block has been loaded into the drawing.

HTH

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Inserting blocks with Tablesearch??
« Reply #3 on: August 11, 2004, 10:24:34 PM »
Rude dog,

The INSERT in your drawing USES the definition of the  BLOCK in the COLLECTION/BLOCKTABLE.

There is nothing further you can do in this regard to make a smaller drawing.
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Inserting blocks with Tablesearch??
« Reply #4 on: August 11, 2004, 10:25:48 PM »
Oops, beaten again by Jeff :)
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.

rude dog

  • Guest
Inserting blocks with Tablesearch??
« Reply #5 on: August 11, 2004, 11:03:21 PM »
I have a lisp routine that creates a 3d object in the backround on layer "0"
after the block is created...the routine calls a nested-routine which names the block<always the same name> and prompts for insertition points..... everytime I initiate the command it recreates the same object...it takes no time for the program to create it <its instanteous> but I was wondering if I was overloading the dwg. a buddy of mine said he could look for the entity name in the table and if it already existed reinsert it thru the table without re-creating it again......I'm probably confusing all Y'ALL.....
I guess ill have to ask him elaborate....Thanks

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Inserting blocks with Tablesearch??
« Reply #6 on: August 11, 2004, 11:09:06 PM »
Quote from: rude dog
< snip > a buddy of mine said he could look for the entity name in the table and if it already existed reinsert it thru the table without re-creating it again......< snip >


That may reduce your processing time, but will not affect the finished drawing size.
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.

rude dog

  • Guest
Inserting blocks with Tablesearch??
« Reply #7 on: August 11, 2004, 11:53:56 PM »
you are probably correct KB...thanks

Quote

That may reduce your processing time


if it can do this that would still be cool

CADaver

  • Guest
Inserting blocks with Tablesearch??
« Reply #8 on: August 12, 2004, 07:48:18 AM »
Code: [Select]
(defun blkchk (nblkname)
  (if (/= (tblsearch "block" nblkname) nil)
    (setq blkchk1 "Y")
    (progn
      (princ "\nBlock not found . . . creating shape.")
      (setq blkchk1 nil)
    )
  )
)


The above subfunction looks for the supplied <nblkname> from some other function in the existing block list for the drawing.  IF found sets "BLKCHK1" to "Y", if not, sets it to nil (i know, i know)

So in the body of your routine you could use something like:

Code: [Select]

(setq blkname <however_it_is_you_get_the_blockname_defined>)      
(blkchk blkname)      
(if (/= blkchk1 "Y")
  (progn
    ( <insert_the_blinking_thing> )
  )
  (progn
    ( <build_the_blinking_thing> )
  )
)


I'm quite sure the masters lurking here can produce a much more elegant code structure, but this concept fits in my head.

rude dog

  • Guest
Inserting blocks with Tablesearch??
« Reply #9 on: August 12, 2004, 09:31:11 PM »
Appreciate the insight....
mabye Texas aint' so bad after all y'all
thanks cadaver i will study this and try it out when my kids let me use my computer  :)