Author Topic: Asking for a lisp to insert blocks relates to list.  (Read 2398 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Asking for a lisp to insert blocks relates to list.
« on: February 06, 2012, 07:33:13 AM »
Hi all

Could some one help me with this lisp?

I want to insert block with attribute related to a list
blocks   already inserted in file

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Asking for a lisp to insert blocks relates to list.
« Reply #1 on: February 06, 2012, 08:35:27 AM »
Need more information.  :-)
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.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Asking for a lisp to insert blocks relates to list.
« Reply #2 on: February 06, 2012, 09:26:51 AM »
Thanks CAB for quick reply

These blocks with attribute are in a file
A
B
C
D

I want to insert them in a column or a row with specified distance depending on a list
A A C D A A D D D .....

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Asking for a lisp to insert blocks relates to list.
« Reply #3 on: February 06, 2012, 10:17:53 AM »
Lets tell all the story

We are structural consultant one of our jobs is creating a Bar Binding List Which has all bars with its data
We draft the bars on the plan then export ATTOUT to modify some data the ATTIN again as a table
The next step is adding a symbol in the table depending on the SHAPE CODE
My planing was to pick the cell then pick SHAPE CODE
the lisp should read the contents of the shape code contents then insert the block then read the next cell contents ( A ) to add in the block attribute then next cell then next cell

I hope that I explained the idea

Attached a part of a file with BBL

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Asking for a lisp to insert blocks relates to list.
« Reply #4 on: February 06, 2012, 03:50:37 PM »
It's been a long time ago that I did anything with tables.
Why don't you update the shape code before the data is imported / created?
A simple lisp could be used to add the shape to PREVIEW that matched the shape code.

Just a suggestion. Obviously I don't know all the processes at work here.
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.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Asking for a lisp to insert blocks relates to list.
« Reply #5 on: February 07, 2012, 01:31:10 AM »
It's been a long time ago that I did anything with tables.
Why don't you update the shape code before the data is imported / created?
A simple lisp could be used to add the shape to PREVIEW that matched the shape code.

Just a suggestion. Obviously I don't know all the processes at work here.

That what I am planing for. But the preview should be has the values
For Example see attached

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Asking for a lisp to insert blocks relates to list.
« Reply #6 on: February 07, 2012, 01:42:37 AM »
These are blocks
there are 2 types one to use in plan and another one to use in table

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Asking for a lisp to insert blocks relates to list.
« Reply #7 on: February 07, 2012, 08:02:43 AM »
This is where I would start:
http://www.theswamp.org/index.php?topic=13878.msg167603#msg167603

The zip file contains the routines.

Just enter the block names in the PREVIEW cells before you bring the table into ACAD.
This section of code will update the block cells.

Code - Auto/Visual Lisp: [Select]
  1. ; This function converts a column of data cell with a blocknames into
  2. ; A column of block cells with symbols
  3.  
  4. (defun AU06:ConvertBlockNameToSymbol (objTable       ; Object Table
  5.                                       intNumColumn   ; Integer Column Index
  6.                                       /
  7.                                       intNumRow      ; Integer Row Index
  8.                                       intObjectID    ; Integer Block Definition Object ID
  9.                                       strBlockName)  ; String Block Name
  10.  (repeat (- (setq intNumRow (vla-get-rows objTable)) 2)
  11.   (setq intNumRow   (1- intNumRow ))
  12.   (and
  13.    (AU06:Errortrap (quote (setq strBlockName (vla-getText objTable intNumRow intNumColumn))))
  14.    (AU06:Errortrap (quote (setq intObjectID (vla-get-objectID
  15.                                              (vla-item
  16.                                               (vla-get-blocks
  17.                                                (vla-get-activedocument
  18.                                                 (vlax-get-acad-object)))
  19.                                               strBlockName)))))                  
  20.    (AU06:Errortrap
  21.     (quote (vla-setcelltype objTable intNumRow intNumColumn acBlockCell)))
  22.    (AU06:Errortrap
  23.     (quote (vla-setblocktablerecordID objTable intNumRow intNumColumn intObjectID :vlax-true)))
  24.    (AU06:Errortrap
  25.     (quote (vla-SetCellAlignment objTable intNumRow intNumColumn acMiddleCenter))))))
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.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Asking for a lisp to insert blocks relates to list.
« Reply #8 on: February 12, 2012, 01:25:29 AM »
Thanks CAB