See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: ADD block preview into a table block table count creator

  1. #1
    Login to Give a bone
    0

    Question ADD block preview into a table block table count creator

    Hey Guys!! I made this lisp by putting together some stuff i found on internet!! the only thing that i would like to do to make it perfect suitable to my own needs is to add the block preview (symbol) into the second collumn.. (witch is already empty as u can see on the Jpg file..)
    i would really apreciate if someane could help me here!!

    thanks
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: ADD block preview into a table block table count creator

    Design Center does a wonderful job of displaying all the blocks in a drawing resized and in alphabetical order. Try putting them all in into one drawing called legend and using a macro with the path and drawing name like:
    Code:
    ^C^C^P(command "adcnavigate" "C:/Blocks/legend.dwg")
    It will open Design Center with your drawing making it easy to insert blocks, layers, linetypes, ect…

  3. #3
    Login to Give a bone
    0

    Default Re: ADD block preview into a table block table count creator

    Hi Tom,

    Sorry, i think i didnt make myself clear... i have a lisp that select some blocks on a drawing and then creates a table with count and atributtes of each block selected... what i need is to put the "preview" (in another words the block itself) on second collumn of the table... (take a look at the image attached on my last post.. there is a table created with the second collum empty.. theres where i would like to my block preview to go..)

    thank you very much, and sorry for not being that clear!! (sorry about my english, as well)

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    1

    Default Re: ADD block preview into a table block table count creator

    Have you tried searching the forums? Maybe this thread has something that would work for you.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Member
    Join Date
    2015-09
    Posts
    5
    Login to Give a bone
    0

    Default Re: ADD block preview into a table block table count creator

    Quote Originally Posted by brunovinicius97767271 View Post
    Hi Tom,

    Sorry, i think i didnt make myself clear... i have a lisp that select some blocks on a drawing and then creates a table with count and atributtes of each block selected... what i need is to put the "preview" (in another words the block itself) on second collumn of the table... (take a look at the image attached on my last post.. there is a table created with the second collum empty.. theres where i would like to my block preview to go..)

    thank you very much, and sorry for not being that clear!! (sorry about my english, as well)
    Look at code from this program by Lee Mac. I'm sure, you will find what you need.
    http://www.lee-mac.com/blockcounter.html

  6. #6
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: ADD block preview into a table block table count creator

    (I revised this code)

    The block image is an interesting aspect of tables.

    I wrote some generalized functions to convert a table column to and from block images.

    I also included a test function that allows the user to select a table and convert one column (0 indexed) to symbols
    given the block name is the text in the cell.

    I also added some errortrapping (stability is important) and the toobjectconvert function is a simplified version of a toolbox
    function I use ALL the time...

    P=

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard C.E., P.E., S.E. copyright 2018 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Any use by unauthorized person or business is strictly prohibited.
    ;___________________________________________________________________________________________________________|
    ;
    ; Abstract: This library provides functions to convert cells in tables to block symbols
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;* C:TableCellSymbol
    ;* Command Line Function to test function to convert a cell in a table to a block symbol
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List 
    ;___________________________________________________________________________________________________________|
    
    ;  Function, Arguments and Description
    
    ;* (ErrorTrap symFunction)
    ;* Function to trap errors. Returns value or T for success and nil for failure
    
    ;* (TableCellBlockNameToSymbol objTable intRow intColumn)
    ;* Function to change a cell in a table to a block symbol (given the text in the cell is a valid block name)
    
    ;* (TableCellBlockSymbolToName objTable intRow intColumn)
    ;* Function to change a cell in a table from a block symbol to a block name
    
    ;* (TableColumnToSymbol objTable intColumn)
    ;* Function to change a column in a table to block symbols (given the text in the table is a valid block name)
     
    ;* (ToObject value)
    ;* Function to convert a vla-object, entitynames, entsels, elists, handles or objectid's to a vla-object.
    
    
    ;$ Header End
    
    ; Function Headers
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function to text Table Column To Symbol function
    ;___________________________________________________________________________________________________________|
    
    (defun C:TableSymbolColumn ()
     (if (and (setq lstSelection (entsel "\nSelect Table: "))
              (setq objTable     (ToObject lstSelection))
              (= (vla-get-objectname objTable) "AcDbTable")
              (setq intColumn (getint "\nEnter Column to convert (0 indexed): "))
              (< -1 intColumn (vla-get-columns objTable))
         )
      (TableColumnToSymbol objTable intColumn)
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to trap errors. Returns value or T for success and nil for failure.
    ;___________________________________________________________________________________________________________|
    
    (defun ErrorTrap (symFunction / objError result XYZ)
     (if (vl-catch-all-error-p
          (setq objError (vl-catch-all-apply
                         '(lambda (XYZ)(set XYZ (eval symFunction)))
                          (list 'result))))
      nil
      (if result result 'T)
     )
    )
    
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to change a cell in a table to a block symbol (given the text in the cell is a valid block name)
    ;___________________________________________________________________________________________________________|
    
    (defun TableCellBlockNameToSymbol (objTable       ; Object Table
                                       intRow         ; Integer Row Index
                                       intColumn      ; Integer Column Index
                                       / 
                                       intObjectID    ; Integer Block Definition Object ID
                                       strBlockName)  ; String Block Name
     (and 
      (setq colBlocks (vla-get-blocks (vla-get-document objTable))) 
      (Errortrap (quote (setq strBlockName (vla-getText objTable intRow intColumn))))
      (Errortrap (quote (setq intObjectID (vla-get-objectID (vla-item colBlocks strBlockName)))))                   
      (Errortrap (quote (vla-setcelltype objTable intRow intColumn acBlockCell)))
      (Errortrap (quote (vla-setblocktablerecordID objTable intRow intColumn intObjectID :vlax-true)))
      (Errortrap (quote (vla-SetCellAlignment objTable intRow intColumn acMiddleCenter)))
     )
    )
    
    
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to change a cell in a table from a block symbol to a block name
    ;___________________________________________________________________________________________________________|
    
    (defun TableCellBlockSymbolToName (objTable       ; Object Table
                                       intRow         ; Integer Row Index
                                       intColumn      ; Integer Column Index
                                       / 
                                       intObjectID    ; Integer Block Definition Object ID
                                       strBlockName)  ; String Block Name
     (and 
      (setq objTable (toobject objTable))
      (setq colBlocks (vla-get-blocks (vla-get-document objTable)))                  
      (Errortrap (quote (vla-setcelltype objTable intRow intColumn acTextCell)))
      (Errortrap (quote (vla-setblocktablerecordID objTable intRow intColumn intObjectID :vlax-false)))
      (Errortrap (quote (vla-SetCellAlignment objTable intRow intColumn acBottomLeft)))
     )
    )
    
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to change a column in a table to block symbols (given the text in the table is a valid block name)
    ;___________________________________________________________________________________________________________|
    
    
    (defun TableColumnToSymbol (objTable       ; Object Table
                                intColumn      ; Integer Column Index
                                / 
                                intRow         ; Integer Row Index
                                intObjectID    ; Integer Block Definition Object ID
                                strBlockName)  ; String Block Name
     (if (and
          (setq objTable (toobject objTable))
          (= (vla-get-objectname objTable) "AcDbTable")
          (setq colBlocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
          (errortrap '(vla-put-RegenerateTableSuppressed objTable 0))
         )
      (progn
       (repeat (- (setq intRow (vla-get-rows objTable)) 2)
         (setq intRow (1- intRow ))
        (TableCellBlockNameToSymbol objTable intRow intColumn)
       )
       (errortrap '(vla-put-RegenerateTableSuppressed objTable 0))
      )
     )
    )
    
    
    
    ;___________________________________________________________________________________________________________
    ; 
    ;  Function to convert a vla-object, entitynames, entsels, elists, handles or objectid's to a vla-object.
    ;___________________________________________________________________________________________________________
    
    
    (defun ToObject (value / symType) 
     (if (and  
          (setq symType (type value))
          (or objDocument
              (setq objDocument (vla-get-activedocument (vlax-get-acad-object)))
          )
          (or (= symType 'vla-object)                
              (and (= symType 'ENAME)                     
                   (setq value (vlax-ename->vla-object value))
              )
              (and (= symType 'STR)
                   (setq value (handent value))         
                   (entget value)
                   (setq value (toobject value))
              )                   
              (and (= symType 'LIST)
                   (= (type (car value)) 'ENAME)  
                   (setq value (toobject (car value)))
              )
              (and (= symType 'LIST)
                   (= (type (car value))  'LIST)                    
                   (= (type (cdar value)) 'ENAME) 
                   (setq value (toobject (cdar value)))    
              )                                      
              (and (= symType 'INT)
                   (= (strlen (itoa value)) 10)
                   objDocument
                   (setq value (errortrap (quote (vla-objectidtoobject objDocument value))))
              )
          )
         )
         value 
     )
    )
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2018-05-26 at 12:17 PM.
    AutomateCAD

  7. #7
    Member
    Join Date
    2012-12
    Posts
    10
    Login to Give a bone
    0

    Default Re: ADD block preview into a table block table count creator

    Hello Peter!
    I came across your great lisp Table Magic once.
    May it be a solution for creating a blocks legend with block insert, attributes and count?
    If I remember your table was able to update the count too, am I right?
    Cheers!

  8. #8
    Member
    Join Date
    2012-12
    Posts
    10
    Login to Give a bone
    0

    Default Re: ADD block preview into a table block table count creator

    Dear Peter,
    Your TableSymbolColumn.lsp does a true magic! I can use it on a table created with autocad Data Extraction. So for me this would be the quickest way to have a table with block miniatures, and all attributes in a table.
    I am only concerned now about the block alignment within tables cells, after I change Block autofit to "NO" and manually adjust the rotation of block in a cell. Block start to fall out of cells.
    Could a code module of TableMagic be used to update alignments of block within cells?
    Also, I wonder what happens when I add blocks, and new rows appear on the data extraction table. Shall the lisp be run again on that table to update appearance?
    Last edited by mikitari; 2019-04-19 at 10:36 AM. Reason: observations on lisp behaviour

Similar Threads

  1. Replies: 8
    Last Post: 2020-10-07, 12:05 AM
  2. Replies: 1
    Last Post: 2017-01-15, 12:22 AM
  3. Block Table inside the Block Editor
    By Wish List System in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2013-11-12, 04:56 PM
  4. Replies: 0
    Last Post: 2013-10-31, 08:42 PM
  5. Block Attribute Table Values Dont' Appear in Block
    By stusic in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2011-12-27, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •