See the top rated post in this thread. Click here

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

Thread: Help Changing text style in blocks

  1. #1
    Member MZerby's Avatar
    Join Date
    2004-11
    Posts
    22
    Login to Give a bone
    0

    Default Help Changing text style in blocks

    Hello again,
    I'm trying to update old drawings and details to our new standards. I was trying to find a way to change all the test and mtext from our old text styles to our new text styles. I have a lisp that will change all the text and mtext that is not in a block. I'm stuck on the one for the text that is embedded in a block though. Below is what I've been working on. I've been stuck for a while now and was hoping someone may be able to see my problem. I'm still pretty new to this.

    Thanks,
    Mike


    Code:
    (defun chblk ()
      (setq objs (ssget "x" '((0 . "INSERT")))
    	in   0
      )
      (repeat (sslength objs)
        (setq ent (ssname objs in)
    	  lst (entget ent)
        )
        (if	(= (cdr (assoc 0 lst)) "INSERT")
          (progn
    	(setq ename (cdr (assoc -1 lst)))
    	(while (setq ename (entnext ename))
    	  (if (or (= (cdr (assoc 0 (entget ename))) "TEXT")
    		  (= (cdr (assoc 0 (entget ename))) "MTEXT")
    	      )				;or
    	    (progn
    	      (setq lst	 (entget ename)
    		    name (cdr (assoc 7 lst))
    	      )
    	      (cond
    		((null name))
    		((= name "Std Text")
    		 (setq lst (subst (cons 7 "FORMAT1") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    
    		((= name "SS")
    		 (setq lst (subst (cons 7 "FORMAT1") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    
    		((= name "S")
    		 (setq lst (subst (cons 7 "FORMAT1") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    
    		((= name "STADARD")
    		 (setq lst (subst (cons 7 "FORMAT1") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    
    		((= name "D")
    		 (setq lst (subst (cons 7 "FORMAT2") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    
    		((= name "T")
    		 (setq lst (subst (cons 7 "FORMAT2") (assoc 7 lst) lst))
    		 (entmod lst)
    		 (entupd (cdr (assoc -1 lst)))
    		 (setq n (+ 1 n))
    		)
    	      )	;cond
    	    )
    	  )
    	)	; if
    
          )		; while
    
          (setq in (1+ in))
        )
    
      )
      (alert (strcat (itoa n) " Items Changed "))
    
    )

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    Try this one

    Thank you

    Fatty
    Attached Files Attached Files

  3. #3
    Member MZerby's Avatar
    Join Date
    2004-11
    Posts
    22
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    Thanks for the code sample. I downloaded it and tried it. Your right about my spelling of STANDARD being wrong. After I corrected my spelling it gave me the error (ActiveX Server returned an error: Parameter not optional) Seemed to be at (vla-put-stylename i new_stl). I've never tried using visual lisp yet, but I think it's because the drawing does have other Text styles in it that I want to let alone and if it's one of those I get a nil for the new_stl variable.

    Does this code change all text and mtext styles or does it just change attribute text styles?

    Thanks,
    Mike

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    This is for attribute text style only so you asked
    Tomorrow I'll can write for the text or MText and for attributes

    Thank you

    Fatty

  5. #5
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    Hi Mike!

    Sorry no time to test this please test yourself

    Thank you

    Fatty
    Attached Files Attached Files

  6. #6
    Woo! Hoo! my 1st post
    Join Date
    2011-11
    Posts
    1
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    I am new to lisp, as in I just started researching them at the beginning of this week. I have a drawing with about 100 blocks and I need to change the text style in each of these blocks from STANDARD to SECURITY.

    If I am reading the post right your lisp will do that, am I correct in that?

    If so, how do I load it? I realize this is a day question to most of you, however this is in fact my day one and I have no formal training on lisp.

    Thank you for you help.

    Nathan

  7. #7
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    1,029
    Login to Give a bone
    1

    Default Re: Help Changing text style in blocks

    I always like it when the code sample is posted.

    Here is something I cooked for this response.

    syntax:

    (changestyle <oldtextstylename> <newtextstylename>)

    P-


    Code:
    (defun ChangeStyle (strStyle1 strStyle2 / entItem objBlock objDocument objItem )
     (vl-load-com)
     (setq objDocument (vla-get-activedocument (vlax-get-acad-object)))
     (if (and (tblobjname "style" strStyle1)
              (tblobjname "style" strStyle2)         
         )
      (vlax-for objBlock (vla-get-blocks objDocument)
       (if (> (vla-get-count objBlock) 0)
        (progn
         (setq objItem (vla-item objBlock 0)
               entItem (vlax-vla-object->ename objItem)
         )
         (while entItem
          (if (and (vlax-property-available-p (setq objItem (vlax-ename->vla-object entItem)) "StyleName")
                   (= (strcase (vla-get-stylename objItem)) (strcase strStyle1))
              )
           (vla-put-stylename objItem strStyle2)
          )
          (setq entItem (entnext entItem))
         )
        )
       )
      )
      (princ "\nError check if styles exist: ")
     )
     (vla-regen objDocument 0)
    )
    AutomateCAD

  8. #8
    Member
    Join Date
    2011-12
    Posts
    11
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    I know this is an old thread but I have a similar problem only the blocks are not created and/or recognized bij autocad
    so block editor won´t work but I do have attributes (?) in the wrong tekst style. Filtering won't work either.
    Does anyone have a lisp to change the tekst style for all tekst or maybe for all attributes in one block?

  9. #9
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,184
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    Quote Originally Posted by sva840811 View Post
    I know this is an old thread but I have a similar problem only the blocks are not created and/or recognized by AutoCAD so block editor won´t work but I do have attributes (?) in the wrong tekst style. Filtering won't work either.
    Does anyone have a lisp to change the tekst style for all tekst or maybe for all attributes in one block?
    Can you attach a small drawing with blocks not created or recognized by AutoCAD with attributes? Only thing I can think of is a label from an AutoCAD verticle like Civil 3D.
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  10. #10
    Member
    Join Date
    2011-12
    Posts
    11
    Login to Give a bone
    0

    Default Re: Help Changing text style in blocks

    I have no idea what program was used but no not recognized and yes actual attributes, I can change the text style for every single attribute but I can't use block editor or the lisps mentioned here, so I have to do it one by one

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2014-08-08, 05:20 PM
  2. Isolate Selected Text Style or Dim Style
    By Wish List System in forum AutoCAD Wish List
    Replies: 4
    Last Post: 2013-01-20, 05:10 AM
  3. Replies: 6
    Last Post: 2010-03-04, 08:59 PM
  4. Changing font without changing Text Style.
    By zoomharis in forum AutoCAD General
    Replies: 7
    Last Post: 2006-03-22, 05:51 PM
  5. Changing text height and style in AutoLISP
    By IanR in forum AutoLISP
    Replies: 7
    Last Post: 2004-07-19, 08:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •