Insertion point and Attribute extraction

Discussion in 'AutoCAD' started by robertlf, Feb 24, 2004.

  1. robertlf

    robertlf Guest

    Hi all gurus.

    Can you please help me with a lisp, to extract all attribute values and the insertion point (X,Y) of block, by picking the block. This block is inserted multiple times in the drawing.
    The extracted values, (Attribute value, X, Y) has then to be written to a table form as shown, within the drawing.

    Value1 - North(Y) - East(X)
    ----A-------1000------1000
    ----B-------2000------1500

    Any help will be appreciated.

    Rob
     
    robertlf, Feb 24, 2004
    #1
  2. robertlf

    hawstom Guest

    What you are contemplating is a pretty robust little application, with lots of facets. Is there a specific question or two that is stumping you?

    You would have to use selection set manipulation, association list access, string manipulation, and file management. All those are subjects in themselves.

    Tom Haws
    Find me at Google
     
    hawstom, Feb 24, 2004
    #2
  3. robertlf

    ECCAD Guest

    Rob,
    The 1st step is to pull the X and Y values.. like so:
    ---------------------------
    ;; Get X and Y values..
    ;;
    (setvar "CMDECHO" 0)
    ;;
    ;; Get the Block in question
    ;;
    (setq ss nil)
    (prompt "\nPick a Block to examine:")
    (setq ss (ssget)); Pick something
    (setq C 0); init
    ;;
    ;;
    (if (/= ss nil)
    (progn
    (setq D (entget (ssname ss C)))
    (if (= "INSERT" (cdr (assoc 0 D))); case of BLOCKS
    (progn
    (setq bn (cdr (assoc 2 D))); get Block Name
    ); end if
    ); end progn
    ;;
    ;; Get selection set of all those blocks
    ;;
    (setq A1 nil)
    (setq A1 (ssget "X")); Select all Blocks
    (setq C 0)
    ;;
    (setq B 0); Set B Len to 0 for init
    (if (/= A1 nil); If A1 (selection set) is nil, do nothing.
    (setq B (sslength A1)); check number of members in 'A1' selection set.
    (setq B 0); else, set length to zero.
    ); end if
    ;;
    ;; A = selection set of entities
    ;; B = sslength of A
    ;; C = Counter for number of entities found
    ;;
    (if (> B 0)
    (progn
    (repeat B
    (setq X nil Y nil ValX "??" ValY "??")
    (setq D (entget (ssname A1 C)))
    (setq chkbn (cdr (assoc 2 D))); get Blockname
    (if (= bn chkbn)
    (progn
    (setq IP (cdr (assoc 10 D))); Insertion Point
    (setq X (car IP)); get X location
    (setq Y (cadr IP)); get Y location
    (if (/= X nil)
    (setq ValX (rtos X))
    ); end if
    (if (/= Y nil)
    (setq ValY (rtos Y))
    ); end if
    (prompt (strcat "\nFound " bn " at:" ValX " " ValY))
    ); end progn
    ); end if
    (setq C (+ C 1) D nil); entity counter
    ); end repeat
    ); end progn
    ); end if
    ); end progn
    ); end if
    (princ)
    ------------------------
    ValX and ValY will be set to the X & Y for each matching block.

    Now we need to know how to 'apply' them in your table.

    Bob
     
    ECCAD, Feb 24, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.