• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    msarqui
    Posts: 89
    Registered: ‎09-14-2010
    Accepted Solution

    Change attribute width

    203 Views, 7 Replies
    01-09-2013 10:15 AM

    Hello,

    I found this routine (http://www.cadtutor.net/forum/showthread.php?47667-Atrribute-width) that changes the width of an attribute in a block. After use it, I need to use the ATTSYNC to update the other instances of the bloc in my project.

    Could someone modify this lisp that I receive a prompt to choose if the width attribute will be change just in the selected block or in all instances of the block? In that way, I would not have to use the ATTSYNC command each time.

     

    Thanks for any help.

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Change attribute width

    01-10-2013 02:22 AM in reply to: msarqui

    msarqui wrote:


     I receive a prompt to choose if the width attribute will be change just in the selected block or in all instances of the block? In that way, I would not have to use the ATTSYNC command each time.

     

    Thanks for any help.

     


    Not sure but, If you do use ATTSYNC anytime within the session, all changes you made on the selected blocks via the routine posted above will revert back to the original.

     

    Does the same thing happens on your end? 

     

    Please use plain text.
    Valued Contributor
    msarqui
    Posts: 89
    Registered: ‎09-14-2010

    Re: Change attribute width

    01-10-2013 05:50 AM in reply to: pbejse

    You have reason pbjese. I did not make myself clear. I'll explain what I need. This is a procedure that I do in all my projects:

     

    During the process to make my projects, I need to change the width of some attributes with the "Enhanced Attribute Editor." After that, I copy this block several times in the project.
    Once the project is finished and built, I need to do the "as built". For this, I edit the block and erase some other attributes. Finally, I use ATTSYNC to update the instances of the block.
    The problem is: after use the ATTSYNC, the change that I did in the width of the attribute with the "Enhanced Attribute Editor" is lost.
    Because of that, I need a routine that allows me to change the width of an attribute in all instances of the block.

    Anyway, it would be nice if the routine could also give me the option to choose if I want to make the width change in just one or in all instances of the block.

     

    I hope I have been more clear now. :smileyhappy:

     

    Thanks!

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Change attribute width

    01-10-2013 06:45 AM in reply to: msarqui

    msarqui wrote:......

     

    Because of that, I need a routine that allows me to change the width of an attribute in all instances of the block.

    Anyway, it would be nice if the routine could also give me the option to choose if I want to make the width change in just one or in all instances of the block.

     

    I hope I have been more clear now. :smileyhappy:

     

    Thanks!


    Sure it can be done. With the option to globally change the width of the selected ATTDEF. would you want that to be permanent and not even ATTSYNC can do anything about it? <unless redefining the block from an external block>

     

     but its going to have to wait until tomorow its quiting time. :smileyhappy:

     

    cheers

     

     

    Please use plain text.
    Valued Contributor
    msarqui
    Posts: 89
    Registered: ‎09-14-2010

    Re: Change attribute width

    01-10-2013 08:55 AM in reply to: pbejse

    pbjse wrote...

     

    would you want that to be permanent and not even ATTSYNC can do anything about it? <unless redefining the block from an external block>

     

    I'm not sure if I understood what you said about it but, I think the answer is yes. I want a permanent change, unless redefining the block from a external block and unless I use the routine again in the same atribute.

     

    And don't be rush, take your time.

     

    Thanks.

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Change attribute width

    01-11-2013 05:11 AM in reply to: msarqui

    msarqui wrote:

     

    I'm not sure if I understood what you said about it but, I think the answer is yes. I want a permanent change, unless redefining the block from a external block and unless I use the routine again in the same atribute.

     

    Thanks.


    (defun c:widedit (/ aDoc x attent uwd option tag blk bn)
    ;;;	pBe 11JN2013	;;;
     (vl-load-com)
     (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) 
     (if (and (setq x (car (nentsel "\nSelect attribute: ")))
     	  (eq "ATTRIB" (cdr (assoc 0 (entget x))))
    	  (setq attent (vlax-ename->vla-object x))
              (princ (strcat "\nCurrent Width is <" (rtos (vla-get-scalefactor attent) 2)"> "))
        	  (setq uwd (getreal "\nEnter new width:  "))) 
      (progn	          
    	(initget "Y N")
    	(setq option (cond
    	               ((getkword "\nApply width to all Attribute of the same block? [Yes/no] <N>: "))
                           ( "N" ))) 
    	(if (eq option "N")
              	(vla-put-scalefactor attent uwd)
                    (progn
                      (setq tag (vla-get-tagstring attent))
                      (setq Blk (vla-ObjectIdToObject aDoc
    					(vla-get-OwnerId  attent))
                            Bn  (vla-get-effectivename blk))
                      (vlax-for itm (vla-item (vla-get-blocks aDoc) bn)
                        	(if (and (eq (vla-get-objectname itm) "AcDbAttributeDefinition")
                        		 (eq (vla-get-tagstring itm) tag))
                              		(vla-put-scalefactor itm uwd)))
    		(vlax-for layout (vla-get-layouts aDoc)
    		    (vlax-for i (vla-get-block layout)
    		      (if (and
    		            (eq (vla-get-objectname i) "AcDbBlockReference")
    		            (eq (Vla-get-hasAttributes i) :Vlax-true)
    		            (eq (vla-get-effectivename i) bn)
    		          )
    		        (foreach itm  (vlax-invoke i 'GetAttributes)
    		                  (if (eq (vla-get-tagstring itm) tag)
    		                      (vla-put-scalefactor itm uwd))
    		          	)
    		          )
    		      	)
    		      )
                      )
              )
        )
       (vl-some
             '(lambda (j) (if (null (eval (car j))) (princ (cadr j))
                  )) 
             '((x "\n<<None Selected>>")
               (attent "\n<<Selected object not an Attribute>>")
               (uwd "\n<<No Width value>>"))
             )
       )
      (princ)
    
    )

     

    Of course , once you decide NOT to apply new width globally, all "fudge" width will revert back to the original when ATTSYNC is invoke. 

     

    USAGE:

    Command: WIDEDIT
    Select attribute:
    Current Width is <1.0000>
    Enter new width: 2
    Apply width to all Attribute of the same block? [Yes/no] <N>:

     

    Default is "No" , only on selected object.

     

    HTH

     

     

    Please use plain text.
    Valued Contributor
    msarqui
    Posts: 89
    Registered: ‎09-14-2010

    Re: Change attribute width

    01-11-2013 10:01 AM in reply to: pbejse

    Dude, the routine is perfect. That was exactly what I needed. Thanks for your work and for being always helpful.

     

    Thank you very much!

    Please use plain text.
    *Expert Elite*
    Posts: 2,136
    Registered: ‎11-24-2009

    Re: Change attribute width

    01-12-2013 08:49 AM in reply to: msarqui

    msarqui wrote:

    Dude, the routine is perfect. That was exactly what I needed. Thanks for your work and for being always helpful.

     

    Thank you very much!


     

    You are welcome msarqui :smileyhappy:

     

    Happy to help 

     

    Cheers

    Please use plain text.