See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Attribute Definition Copying Routine

  1. #1
    Member
    Join Date
    2014-10
    Posts
    17
    Login to Give a bone
    0

    Default Attribute Definition Copying Routine

    Ok... so relatively new here, so I'll apologize in advance!

    What I am in search of is a Lisp routine (or other) that will copy the Tag definition of an attribute and paste the same value into the default value. Currently I have to double click the attribute, hit cntrl+c, click in the Default field and then hit cntrl+v to paste the value to the default location. If there is a faster/easier/more efficient way... I'm all ears... Thanks in advance!!!!!!


    MT

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

    Default Re: Attribute Definition Copying Routine

    I have no idea what you just said.

    What is the purpose of copying the tag definition of an attribute to label it as the default value? How often would you use this routine?
    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

  3. #3
    Member
    Join Date
    2014-10
    Posts
    17
    Login to Give a bone
    0

    Default Re: Attribute Definition Copying Routine

    We use it for part numbers in detail blocks. I do this very frequently. If there was a faster, more efficient way of doing it, I'd be all ears.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Attribute Definition Copying Routine

    Hi ,

    I think , you can not copy the Tag definition from the Value cell but the value of the attribute unless you mean that you rewrite the value as you can see the Tag attribute straight from the Enhanced Attribute Editor .

    Are you about to change all attributes in a Block ?

    Something like this ?

    Code:
    (defun c:Test (/ s )
      (princ "\n Pick Attributed Block :")
      (if (setq s (ssget "_+.:S:E:L" '((0 . "INSERT")(66 . 1))))
        (mapcar '(lambda (u) (vla-put-textstring u (vla-get-tagstring u)))
                (vlax-invoke (vlax-ename->vla-object (ssname s 0)) 'GetAttributes))
        )
      (princ)
      )(vl-load-com)

  5. #5
    I could stop if I wanted to
    Join Date
    2015-10
    Location
    Colorado Springs, CO
    Posts
    369
    Login to Give a bone
    0

    Default Re: Attribute Definition Copying Routine

    Maybe I'm missing something... wouldn't redefining the block to have the tag and the default value be the same make this easier? Or does the tag somehow vary?

  6. #6
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Attribute Definition Copying Routine

    Quote Originally Posted by Coloradomrg View Post
    Maybe I'm missing something... wouldn't redefining the block to have the tag and the default value be the same make this easier? Or does the tag somehow vary?
    I think what he's saying is sometimes the value that has been entered in the block is not the default value, and he's looking for a way to force them all to be the default value.

    I may be wrong.. I think we need more info.

    Like is the value going to be the same always for that block?
    Or does it change per instance or project?

  7. #7
    Member
    Join Date
    2015-11
    Location
    Highlands ranch, CO
    Posts
    29
    Login to Give a bone
    1

    Default Re: Attribute Definition Copying Routine

    This LISP From Lee Lets you copy or swap text & attributes:
    http://www.lee-mac.com/copytext.html

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

    Default Re: Attribute Definition Copying Routine

    The default value for an attribute is stored in the block definition.

    Below is some code that will allow the user to create a selection set of blocks.

    The routine will look at each block instance and find its block definition and create a list of sublists including the
    tagstring and default textstring for each attribute.

    Then it will check to see if the length of attributes in the block instance and the length of that list of sublists are equal.
    It then checks to see if the tagstrings are the same.

    If they are... it changes the textstring in each of the attributes to the default te.

    It will not work if you have modified the attributes (number or order) after the creation of the block.

    I believe that is what you asked for, or is it opposite?

    P=

    Code:
    ;___________________________________________________________________________________________________________
    ;
    ; Function for returning block attributes to default values
    ; Written By: Peter Jamtgaard copyright 2014 all rights reserved
    ;  
    ;___________________________________________________________________________________________________________
    
    (defun C:Default (/ intCount entSelection lstAttributes lstDefaults objSelection ssSelections )
     (if (setq ssSelections (ssget (list (cons 0 "insert"))))
      (repeat (setq intCount (sslength ssSelections))
       (and
        (setq intCount     (1- intCount))
        (setq entSelection (ssname ssSelections intCOunt))
        (setq objSelection (vlax-ename->vla-object entSelection))
        (= (vla-get-hasattributes objSelection) :vlax-true)
        (setq lstAttributes (vlax-invoke objSelection "getattributes"))
        (setq lstDefaults   (attributedefaults objSelection))
        (defaultset objSelection)
       )
      )
     )
     (princ)
    )
    
    ;___________________________________________________________________________________________________________
    ;
    ; Function for checking the tagstring and number of attributes and changing them to default values
    ;___________________________________________________________________________________________________________
    
    (defun DefaultSet (objSelection)
     (or
      (and
       (= (length lstAttributes) (length lstDefaults))
       (equal (mapcar 'vla-get-tagstring lstAttributes)
              (mapcar 'car lstDefaults)
       )
       (mapcar 'vla-put-textstring lstAttributes (mapcar 'cadr lstDefaults))
      )
      (princ "\nError: The attributes have changed from the definition.")
     )
    )
    
    ;___________________________________________________________________________________________________________
    ;
    ; Function for getting the tagstring and default values from a block definition
    ;___________________________________________________________________________________________________________
    
    (defun AttributeDefaults (objSelection / lstOfSublists)
     (vlax-for objItem (blockdefinition objSelection)
      (and 
       (wcmatch (vla-get-objectname objItem) "AcDbAttributeDefinition")
       (setq lstOfSublists (cons (list (vla-get-tagstring objItem)(vla-get-textstring objItem)) lstOfSublists))   
      )
     )
     (reverse lstOfSublists)
    )
    
    ;___________________________________________________________________________________________________________
    ;
    ; Function for getting a block definition object from the block object.
    ;___________________________________________________________________________________________________________
    
    
    (defun BlockDefinition (objSelection / objReturn)
     (if (and (wcmatch (vla-get-objectname objSelection) 
                       "AcDbBlockReference,AcDbMInsertBlock")
              (setq objReturn (vla-item (vla-get-blocks 
                                         (vla-get-document objSelection))
                                        (vla-get-name objSelection)
                              )
              )
         )
      objReturn
     )
    )
    
    (prin1)
    Attached Files Attached Files
    Last edited by peter; 2014-12-24 at 09:09 PM.
    AutomateCAD

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

    Default Re: Attribute Definition Copying Routine

    If you are editing a block and want to change the default textstring of an attdef to be equal to the tagstring...

    P=

    Code:
    (defun C:TagstringToDefault (/ intCount entSelection objSelection ssSelections )
     (if (setq ssSelections (ssget (list (cons 0 "attdef"))))
      (repeat (setq intCount (sslength ssSelections))
       (and
        (setq intCount     (1- intCount))
        (setq entSelection (ssname ssSelections intCOunt))
        (setq objSelection (vlax-ename->vla-object entSelection))
        (vla-put-textstring objSelection (vla-get-tagstring objSelection))
       )
      )
     )
     (princ)
    )
    AutomateCAD

  10. #10
    Member
    Join Date
    2014-10
    Posts
    17
    Login to Give a bone
    0

    Default Re: Attribute Definition Copying Routine

    Thanks for the replies!! Peter NAILED IT!! That silly bit of code will save my company a tremendous amount of time! Thank you!!

    Chris

Page 1 of 2 12 LastLast

Similar Threads

  1. Attribute Definition Value List
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2014-07-15, 01:31 PM
  2. Turn Text in Attribute definition
    By procique in forum AutoCAD General
    Replies: 1
    Last Post: 2011-02-14, 02:07 PM
  3. Attribute definition field formatting removal
    By some buddy in forum AutoLISP
    Replies: 11
    Last Post: 2010-10-28, 10:57 PM
  4. Attribute Definition Issue (Scaling)
    By vcerro in forum AutoCAD General
    Replies: 2
    Last Post: 2010-06-04, 01:21 PM
  5. Remove attribute from a block definition
    By avatar in forum AutoLISP
    Replies: 3
    Last Post: 2010-03-08, 12:29 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
  •