Visual LISP, AutoLISP and General Customization

Reply
Contributor
mewescott
Posts: 21
Registered: ‎02-10-2011
Message 1 of 10 (224 Views)
Accepted Solution

Change font of named Attribute through out drawing

224 Views, 9 Replies
09-25-2012 04:09 AM

Does anyone know how to change the font of a specific attribute in all my blocks in a drawing.  I am trying to change the INST attribute font to Arial but I have thousands of them through out my project.  My other attributes that I do not want to change are using the same Style as this block so I can not simply change the style.

Distinguished Mentor
_Tharwat
Posts: 557
Registered: ‎07-02-2010
Message 2 of 10 (213 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 06:28 AM in reply to: mewescott

AFAIK you can not change the font of the attributed block string , and changing fonts would affect on text styles in tables , anyway create a TEXT STYLE named ARIAL and try this piece of code .

 

(defun c:TesT (/ Unlock-layers lock-layers l lst ss n e i)
  ;; 		 Tharwat 17. Sep. 2012   			;
  ;;          Change a specific attributed ' Value style name	;
  ;;                             to ARIAL			;
  (while (setq l (tblnext "LAYER" (null l)))
    (if (eq (Logand 4 (cdr (assoc 70 l))) 4)
      (setq lst (cons (cdr (assoc 2 l)) lst))
      )
    )
  (defun Unlock-layers (layerlist / tbl)
    (foreach x layerlist
      (if (tblsearch "LAYER" x)
        (entmod (subst (cons 70 0) (assoc 70 (setq tbl (entget (tblobjname "LAYER" x)))) tbl))
        )
      )
    (command "_.regen")
    )
  (defun lock-layers (layerlist / tbl)
    (foreach x layerlist
      (if (tblsearch "LAYER" x)
        (entmod (subst (cons 70 4) (assoc 70 (setq tbl (entget (tblobjname "LAYER" x)))) tbl))
        )
      )
    (command "_.regen")
    )
  (if (and (tblsearch "STYLE" "ARIAL") (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))))
    (progn (if lst
             (Unlock-layers lst)
             )
           (repeat (setq i (sslength ss))
             (setq n (entnext (ssname ss (setq i (1- i)))))
             (while (not (eq (cdr (assoc 0 (setq e (entget n)))) "SEQEND"))
               (if (eq (cdr (assoc 1 e)) "INST")
                 (entmod (subst (cons 7 "ARIAL") (assoc 7 e) e))
                 )
               (setq n (entnext n))
               )
             (setq n nil)
             )
           (if lst
             (lock-layers lst)
             )
           )
    (princ)
    )
  (princ)
  )

Tharwat

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Distinguished Mentor
Moshe-A
Posts: 711
Registered: ‎09-14-2003
Message 3 of 10 (201 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 07:19 AM in reply to: _Tharwat

Tharwat,

 

why BEDIT + ATTSYNC is not enough?

 

moshe

Contributor
mewescott
Posts: 21
Registered: ‎02-10-2011
Message 4 of 10 (200 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 07:32 AM in reply to: _Tharwat

Tharwat,

 

Thank you, but it did not work.  It did ask to select objects but it did nothing to them.

Contributor
mewescott
Posts: 21
Registered: ‎02-10-2011
Message 5 of 10 (199 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 07:34 AM in reply to: Moshe-A

Bedit with ATTSYNC would work if it was only a couple of blocks.  I may have anywhere from 20 to 50 blocks per drawing with the same INST attribute that I want to change.

Distinguished Mentor
_Tharwat
Posts: 557
Registered: ‎07-02-2010
Message 6 of 10 (186 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 08:47 AM in reply to: mewescott

Hi ,

 

It should work except if you do not have the attribute value INST within the selected blocks .

 

can you upload a sample drawing ?

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Distinguished Mentor
_Tharwat
Posts: 557
Registered: ‎07-02-2010
Message 7 of 10 (185 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 08:49 AM in reply to: Moshe-A

You are right Moshe , but the OP have many different blocks as he/she mentioned that in post No. 5

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Distinguished Mentor
Moshe-A
Posts: 711
Registered: ‎09-14-2003
Message 8 of 10 (184 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 08:51 AM in reply to: mewescott

i'm sorry i meant BATTMAN (instead of bedit+attsync)

 

if the problem is a text style? why don't you consider modifiy it to use the right font file

(even change it's name if needed)

 

moshe

 

 

 

 

 

 

Distinguished Mentor
_Tharwat
Posts: 557
Registered: ‎07-02-2010
Message 9 of 10 (182 Views)

Re: Change font of named Attribute through out drawing

09-25-2012 08:55 AM in reply to: Moshe-A

Moshe-A wrote:

if the problem is a text style? why don't you consider modifiy it to use the right font file

(even change it's name if needed)

 

moshe

 


You may need to re-read the first post again Moshe . :smileywink:

 

The OP wants specific attribute entity with vallue and not the text style that holds them .

 

 

 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Contributor
mewescott
Posts: 21
Registered: ‎02-10-2011
Message 10 of 10 (157 Views)

Re: Change font of named Attribute through out drawing

09-27-2012 10:26 AM in reply to: _Tharwat

I do have multiple blocks with the same attribute name that I want to change the font on.  I have received a solution to my posting in the posting I put on the Autocad Electrical forum.  Pat Muren created a custom lisp file and script that worked like a charm.  To view the posting go to:  http://forums.autodesk.com/t5/AutoCAD-Electrical/Change-the-font-of-the-Installation-code-through-ou...

 

Thank you for assistance.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community