Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change attribute width

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
msarqui
2464 Views, 14 Replies

Change attribute width

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.

 

14 REPLIES 14
Message 2 of 15
pbejse
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? 

 

Message 3 of 15
msarqui
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. 🙂

 

Thanks!

Message 4 of 15
pbejse
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. 🙂

 

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. 🙂

 

cheers

 

 

Message 5 of 15
msarqui
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.

Message 6 of 15
pbejse
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

 

 

Message 7 of 15
msarqui
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!

Message 8 of 15
pbejse
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 🙂

 

Happy to help 

 

Cheers

Message 9 of 15
bcorvera
in reply to: pbejse

I need this too. Thanks a lot!

Message 10 of 15
vravkovsky
in reply to: pbejse

Found this post through a search engine. Is there any way to use the code only on preselected objects? It works fine, thanks, but not exactly the way I need 🙂

Message 11 of 15
pbejse
in reply to: vravkovsky


@vravkovsky wrote:

Found this post through a search engine. Is there any way to use the code only on preselected objects? It works fine, thanks, but not exactly the way I need 🙂


Yes

And how exactly do you need it vravkovsky? please explain buddy

 

pBe

 

Message 12 of 15
vravkovsky
in reply to: pbejse

Correct me if I'm wrong, I tried your code on one of the drawings, I needed to process, and found that it changes the attribute width in all the block instances. Am I wrong, or is there any way to change the code so, that it would utilise pre-selection?

Message 13 of 15
pbejse
in reply to: vravkovsky


@vravkovsky wrote:

Correct me if I'm wrong, I tried your code on one of the drawings, I needed to process, and found that it changes the attribute width in all the block instances. Am I wrong, or is there any way to change the code so, that it would utilise pre-selection?


You are correct, the routine does exactly what you describe.

 

Look here --->> Edit block attribute properties  [post#13] if any of that works for you vravkovsky.

 

 

 

Message 14 of 15
pbejse
in reply to: pbejse


@vravkovsky wrote:

.....Am I wrong, or is there any way to change the code so, that it would utilise pre-selection?


perhaps this?

 

 

(defun C:demo (/ ThisAttDef)
      (vl-load-com)
      (or wid (setq wid 1.00))
      (setq wid (cond 
                      ((getreal
                             (strcat "\nEnter Width <"
                                     (rtos wid 2 2)
                                     ">: ")))
                      (wid)))

  		(While
		  (Setq ThisAttDef (car (nentsel "\nSelect Attribute")))
		   (vla-put-ScaleFactor
		     (vlax-ename->vla-object ThisAttDef)
		     wid
		   )
		)
  )

 

Message 15 of 15
vravkovsky
in reply to: pbejse

Nope, this one requires clicking on each attribute in each instance of block. Becides it ignores pre-selection.

I guess, the code that is closest to my needs was published in the thread, given by you a message above. Gws function does almost exactly what's needed. Though, if instances of several different blocks with the same attribute definition are selected, it corrects the ratio only for one of them. Like I have a definition of blockA and blockB, which both have a defined attribute AttrB - if I select several copies of blockA and several copies of blockB, the ratio of AttrB is corrected only in instances of blockA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost