+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Super Member MarcoW's Avatar
    Computer Details
    MarcoW's Computer Details
    Operating System:
    Microsoft Windows 7 Pro 64-bit
    Computer:
    A black one
    CPU:
    Intel Xeon E5520 Quad Core
    RAM:
    8 GB
    Graphics:
    NVIDIA Quadro FX 580 - 512MB
    Primary Storage:
    300 GB 10000 RPM
    Using
    AutoCAD 2011
    Join Date
    Apr 2009
    Location
    The Netherlands
    Posts
    599

    Smile Creating tool (lisp) for copy attribute and global attribute edit

    Registered forum members do not see this ad.

    After having inserted multiple blocks in a drawing, the attributes must be filled in. Now i use "ddatte" per block, so 100 blocks means 100 times ddatte and then fill in.

    Another way is by selecting the blocks that are the same an then use "props" to fill out the fields.

    Can it be done with lisp, like "global attribute edit"..?
    i.e.: 1. invoke command like "gae" 2. prompt for reference block -> select block 3. get dialog (same as ddatte dialog box) 4. fill it out 5. select blocks (per block or via crossing) 6. selected blocks are filled out.

    And is it possible to copy the attribute values of a block (that has been filled out) to another?

    Got a million ideas but first this one !

  2. #2
    Super Member MarcoW's Avatar
    Computer Details
    MarcoW's Computer Details
    Operating System:
    Microsoft Windows 7 Pro 64-bit
    Computer:
    A black one
    CPU:
    Intel Xeon E5520 Quad Core
    RAM:
    8 GB
    Graphics:
    NVIDIA Quadro FX 580 - 512MB
    Primary Storage:
    300 GB 10000 RPM
    Using
    AutoCAD 2011
    Join Date
    Apr 2009
    Location
    The Netherlands
    Posts
    599

    Default

    Registered forum members do not see this ad.

    Found the command "gatte" within the express menu.
    I can and wil use it but how can the routine be modified so it does the thingy to all the attributes belonging to the block?

    Ie. a block with 3 filled out attributes, copy all attributes to the other blocks.

    ;;
    ;;;
    ;;; GATTE.LSP
    ;;; Copyright © 1999 by Autodesk, Inc.
    ;;;
    ;;; Your use of this software is governed by the terms and conditions of the
    ;;; License Agreement you accepted prior to installation of this software.
    ;;; Please note that pursuant to the License Agreement for this software,
    ;;; "[c]opying of this computer program or its documentation except as
    ;;; permitted by this License is copyright infringement under the laws of
    ;;; your country. If you copy this computer program without permission of
    ;;; Autodesk, you are violating the law."
    ;;;
    ;;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
    ;;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
    ;;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
    ;;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
    ;;; UNINTERRUPTED OR ERROR FREE.
    ;;;
    ;;; Use, duplication, or disclosure by the U.S. Government is subject to
    ;;; restrictions set forth in FAR 52.227-19 (Commercial Computer
    ;;; Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
    ;;; (Rights in Technical Data and Computer Software), as applicable.
    ;;;
    ;;; ----------------------------------------------------------------

    (Defun C:gatte ( /
    N ;selection set counter
    CC ;changed counter
    BN ;block name
    TG ;tag name
    ESel ;entity pick/name/list
    EL ;entity list
    EN ;entity name
    PASS ;loop pass flag
    TAGL ;list of valid tags for a block
    TAGS ;String of valid tags for a block
    TAGT ;Temp tag list
    ;TAG ;tag name in loop
    TMP ;temporary variable
    SS1 ;selection set of insert objects
    XX X ;flag and counter
    OLDCC ;previous count of changes for update test
    A ;entity information in change loop
    FL LA ;frozen layer check variables
    na b
    )

    (acet-error-init
    (List
    (List "cmdecho" 0)
    T ;flag. True means use undo for error clean up.
    ) ;list
    );acet-error-init
    (sssetfirst nil nil)
    ;;
    (Setq n 0
    cc 0
    )
    (while (null Pass)
    (initget "Block _Block")
    ;; (setq ESel (entsel "\nBlock name/<select block or attribute>: "))
    (setq ESel (entsel "\nSelect block or attribute [Block name]: "))
    (cond
    ((null ESel) (setq Pass 'T BN nil))
    ((= (type ESel) 'LIST) ;;pick selection
    (setq EL (entget (car ESel)))
    (if (= (cdr (assoc 0 EL)) "INSERT")
    (setq BN (cdr (assoc 2 EL))
    Pass 'T
    ESel (nentselp (cadr ESel))
    EL (entget (car Esel))
    TG (if (= (cdr (assoc 0 EL)) "ATTRIB")
    (cdr (assoc 2 EL))
    nil
    )
    )
    (prompt "\nSelected item not an INSERT.")
    );end if
    );end second conditional for picking attrib
    ((and (= (type ESel) 'STR) (= ESel "Block"))
    (setq BN (getstring "\nEnter block name: "))
    (if (tblsearch "BLOCK" BN)
    (setq Pass 'T)
    (prompt "\nInvalid block name.")
    )
    );end third conditional
    );the conditional statement ends
    ) ;;end of Block Name entry.

    (if BN (progn
    (setq Pass nil
    EN (cdr (assoc -2 (tblsearch "BLOCK" BN)))
    )
    (while EN
    (setq EL (entget EN))
    (if (= (cdr (assoc 0 EL)) "ATTDEF")
    (setq TAGL (cons (cdr (assoc 2 EL)) TAGL)))
    (setq EN (entnext EN))
    )
    )) ;;end if BN progn
    (if TG (setq Pass 'T))

    (if TAGL
    (progn
    (setq TAGS (car TAGL)
    TAGT (cdr TAGL)
    )
    (foreach TAG TAGT
    (setq TAGS (strcat TAGS " " TAG))
    )
    )
    )

    (while (and TAGS (null Pass))
    (initget TAGS)
    (prompt (strcat "\nKnown tag names for block: " TAGS))
    (setq ESel (nentsel "\nSelect attribute or type attribute name: "))

    (cond
    ((= (type ESel) 'STR)
    (setq ESel (xstrcase ESel))
    (if (member ESel TAGL)
    (setq Pass 'T
    TG ESel
    )
    (prompt "\nInvalid attribute name.")
    )
    )
    ((= (type ESel) 'LIST) ;;pick selection
    (setq TG (cdr (assoc 2 (entget (car ESel)))))
    (if TG
    (setq Pass 'T)
    )
    )
    );the conditional statement ends
    ) ;;end of Attribute Name entry.


    (if (and BN (null TAGL))
    (setq BN (prompt "\nThe block selected has no attributes!")))
    (If (And BN TG)
    (Progn
    (prompt (acet-str-format "\nBlock: %1 Attribute tag: %2" BN TG))
    (Setq
    NA (GetString T "\nEnter new text: ")
    SS1 (SsGet "_X"
    (List
    (Cons 0 "INSERT")
    (Cons 2 bn)
    (Cons 66 1)
    )
    )
    N (If SS1 (SsLength SS1) 0)
    )
    (initget 0 "Yes No _Yes No")
    (setq TMP
    (getkword
    (acet-str-format "\nNumber of inserts in drawing = %1 Process all of them? [Yes/No] <Yes>: " (itoa N))))
    (if (and TMP (= TMP "No"))
    (setq SS1 (ssget (list (cons 0 "INSERT")
    (cons 2 BN)
    (cons 66 1)))
    N (if SS1 (sslength SS1) 0)
    )
    )
    (if (> N 0) (Princ "\nPlease wait..."))
    (setq x 0)
    (repeat N
    (setq A (ssname SS1 x)
    B (entget A)
    la (cdr (assoc 8 B)) ;layer name from object
    fl (tblsearch "LAYER" la) ;table entry for layer
    fl (cdr (assoc 70 fl)) ;layer status flag
    )
    (if (/= fl 65) ;if layer not frozen
    (progn
    (setq XX 1
    oldcc cc)
    (while XX
    (setq
    B (EntGet (EntNext (CDR (Assoc -1 B))))
    )
    (If (= (CDR (Assoc 0 B)) "SEQEND")
    (Setq xx Nil)
    (Progn
    (If (= (CDR (Assoc 2 b)) tg)
    (Progn
    (Setq B (subst (Cons 1 NA) (assoc 1 B) B)
    CC (1+ CC)
    )
    (EntMod B)
    ) ;progn
    ) ;if
    ) ;progn
    ) ;if
    ) ;while
    (If (/= cc oldcc) (EntUpd a))
    ) ;progn
    ) ;if
    (Setq X (1+ X))
    ) ;repeat
    (If (/= 1 cc)
    (princ (acet-str-format "\n%1 attributes changed." (itoa cc)))
    (princ (acet-str-format "\n%1 attribute changed." (itoa cc)))
    )
    ) ;progn
    )
    (acet-error-restore)
    (Princ)
    ) ;defun

    (princ)

Similar Threads

  1. Numerical Global Block Attribute
    By kristin in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 16th Jun 2011, 10:52 am
  2. Global attribute properties changes in a block?
    By muck in forum AutoCAD General
    Replies: 3
    Last Post: 30th Dec 2008, 07:04 pm
  3. Global Attribute command
    By Scott44 in forum AutoCAD General
    Replies: 1
    Last Post: 18th Jun 2008, 11:22 pm
  4. Problem With Global Attribute Editing
    By Lucid in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 7th Dec 2007, 03:43 pm
  5. how can i edit an attribute
    By fides in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 19th Jan 2007, 02:38 am

Bookmarks

Posting Permissions

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