Select Blocks, Change Attribute Text Style, Attsync

Select Blocks, Change Attribute Text Style, Attsync

Anonymous
Not applicable
4,661 Views
11 Replies
Message 1 of 12

Select Blocks, Change Attribute Text Style, Attsync

Anonymous
Not applicable

First, I think it would be helpful to explain my workflow. I have searched through the forums but couldn't find anything quite like what I need.  I am new to lisp but know enough to modify existing codes, so I don't mind tinkering with the code. I'm here to learn as well. If you have any questions for me, please send them my way. Thanks!

 

Workflow

1. BEDIT, Select Block.

2. Within Block Editor, I select the attributes and change the Text Style from "RomanS to XXX-ARIAL.

3. Close Block Editor.

4. ATTSYNC.

 

Known Issues

1. XXX-ARIAL Text Style not in every .dwg. I often add this Text Style through Design Center.

 

Other

  • Would like to automate these tasks.
  • If there is a better solution than a lisp, I'm definitely open to suggestions. My goal is efficiency.
  • The office I work in is updating their standards, so this process needs to be done in hundreds of drawings.
Accepted solutions (1)
4,662 Views
11 Replies
Replies (11)
Message 2 of 12

dlanorh
Advisor
Advisor

Are you changing every attribute in every block as i have a lisp that does this?

I am not one of the robots you're looking for

Message 3 of 12

dbhunia
Advisor
Advisor
@Anonymous wrote:

 

Workflow

1. BEDIT, Select Block.

2. Within Block Editor, I select the attributes and change the Text Style from "RomanS to XXX-ARIAL.

3. Close Block Editor.

4. ATTSYNC.

 

Known Issues

1. XXX-ARIAL Text Style not in every .dwg. I often add this Text Style through Design Center.

 

Hi,

 

Check the below code........(According to your workflow)......

(It works fine in AutoCAD 2007 & hopefully it will work in latest version, otherwise let inform me....)

 

(defun c:DEBA (/)
(setq Data (ENTGET (CAR (ENTSEL "\nSelect The Block: "))))
(setq B_Name (cdr (assoc 2 Data)))
(COMMAND "BEDIT" B_Name)
(Setq selectionset (ssget))
(setq New_Style (getstring "\nInput New Text Style: "))
(repeat (setq N (sslength selectionset))
(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq Text_Style (cdr (assoc 7 EntityData)))
(setq EntityData (subst (cons 7 New_Style)(assoc 7 EntityData)EntityData))
(entmod EntityData)
)
(COMMAND "BCLOSE" "S")
(command "ATTSYNC" "N" B_Name)
)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 4 of 12

pbejse
Mentor
Mentor

@NM_Design wrote:

 

 

Known Issues

1. XXX-ARIAL Text Style not in every .dwg. I often add this Text Style through Design Center.

 


 

If the users are individually opening the files.

  • Put the "corrected" block on the tool palette.
  • Hover over the item on the tool palette
  • Right-click / Redefine 
  • All done.

 

Now if you need a program to run on multiple files, then we write a program

 

 

 

Message 5 of 12

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous hi,

 

first I'm sure there are 'tones' of codes in this forum (and others) about what you want cause you still not in AutoLISP, you do not know how or where to look, but lets ignore that.

 

when you'll better know AutoLISP you will see that there are other way to modify attributes properties without going to BEDIT cause infect BEDIT comes to AutoCAD only in R2006 but before that we still could do what you want and mush more.

 

you say you want to learn?

you know enough to modify existing codes?

I am picking the Glove and challenging you.

 

do you know the difference between block definition and block reference?

 

the following command function (c:cbas) Change Block Attribute Style do what you want but it lack of two parts left for you to complete. each line code has it's comment for you to understand.

(in VisualLISP\ActiveX there is more sophisticated way to do this)

 

enjoy

moshe

 

 

; change block attribute text style
(defun c:cbas (/ newStyle ss ename0 edata0 bname tbl ename1 edata1 ;| local variables |;)
 (setq newStyle "XXX-ARIAL")
 ; load "XXX-ARIAL" text style here
 ; ......
  
 ; next expession pause for user selection,
 (if (setq ss (ssget ":S:E" '((0 . "insert") (66 . 1))))  ; select only 1 block reference that contain attributes 
  (progn
   (setq ename0 (ssname ss 0)) 	; get entity name of the first entity in selection set
   (setq edata0 (entget ename0))  	; get entity database list
   (setq bname (cdr (assoc '2 edata0)))	; get block name

   (if (setq tbl (tblsearch "block" bname)) 	; get block definition database list
    (progn
     (setq ename1 (cdr (assoc '-2 tbl))) ; get ename of the first entity in block definition
     
     (while ename1 ; while there is still entities in block definition
      (setq edata1 (entget ename1)) ; get entity database list
       
      (if (eq (cdr (assoc '0 edata1)) "ATTDEF") ; is it attribute definiton?
       (progn
	; modify attribute database 
        (setq edata1 (subst
		       (cons  '7 newStyle)   ; new style
		       (assoc '7 edata1)     ; existing style 
		       edata1		     ; in this database list
		     ); subst function
	); setq 
        (entmod edata1) ; update database
       ); progn
      ); if

      (setq ename1 (entnext ename1)) ; get next entity, return nil when no more entities found in block definition
     ); while
    ); progn
   ); if

   ; do your block syncronize here
   ; .....
   
  ); progn
 ); if
 
 (princ) ;quiet exit
); c:cbas

 

 

 


Message 6 of 12

Moshe-A
Mentor
Mentor

Rayn,

 

whats up?

 

please mark this thread as your solution - thank you

Message 7 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

  • The office I work in is updating their standards, so this process needs to be done in hundreds of drawings.

 

That suggests to me that you would want to do it in all  Block definitions, and if that could, in some drawings, include some Blocks that are defined  in the drawing but of which there are currently no insertions, then you probably want an approach that does not depend on object selection at all.  After all, with an object-selection-based approach [even if a routine finds all Block insertions for itself, without User  selection], if someone later Inserts a Block that didn't have any insertions at the time of running the routine, it won't have had its Attribute Text Style updated, and the User will need to run the routine again on that Block [if they notice the difference].

 

Also, if you want to hit all Blocks definitions, a tool-palette redefinition approach [or similarly through the Design Center] wouldn't be practical, as it would require an item for every possible Block definition that contains any Attributes.

 

That's why I'd go for an approach that steps through the Block table, and does it in all Block definitions.  Does that sound like the way to go?  [The offering from @dlanorh may work that way -- I couldn't say, but Reply to that and ask for it.]

 

Do you need all  Attributes in all  Blocks to be changed to the same  target Style, or only those that are currently in a particular  other Style ["ROMANS" in your description], leaving alone any Attributes in other Styles?

Kent Cooper, AIA
Message 8 of 12

pbejse
Mentor
Mentor

@Kent1Cooper wrote:

Also, if you want to hit all Blocks definitions, a tool-palette redefinition approach [or similarly through the Design Center] wouldn't be practical,.

     ..leaving alone any Attributes in other Styles?


 

We will all know what is what if only the OP will reply but...

 

NM_Design.png

 

One here and two elsewhere and...

 

download.jpg

 

I'm sure the solution is going to be simple and easy... <-Hope don't get any reactions from that statement Smiley LOL

 

 

Message 9 of 12

Anonymous
Not applicable

Sorry everyone! My work e-mail was blocking all replies, so I didn't realize there were any messages. I don't have access to my computer this weekend but I promise to not leave you hanging!!

0 Likes
Message 10 of 12

Anonymous
Not applicable

Thank you, Moshe-A. I do not have access to my CAD computer this weekend but I'm definitely interested in learning.  I'm very much a beginner though and I appreciate your challenge! I will give it a shot but it may just take me a bit of time. 

0 Likes
Message 11 of 12

Anonymous
Not applicable

Kent,

 

Yes, that does sound like the approach I'm after.

 

I only needs the blocks that are in a particular style ["ROMANS"] since some blocks use a different style that I would rather not change.  There are only a handful of blocks that are giving me issues (some blocks are fine) but they are in 100's of drawings, so it can be a bit tedious.

 

I think changing all blocks and all attributes may be something I develop in the future but for now, I'd like to be a little more selective.

0 Likes
Message 12 of 12

Anonymous
Not applicable

dlanorh,

There are only a few blocks that are giving me issues but I could see your lisp being handy.  I'd definitely be interested in trying it out if you're willing to share!

0 Likes