TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on January 03, 2011, 10:21:54 AM

Title: How to change texstyle of sellected dtext
Post by: GDF on January 03, 2011, 10:21:54 AM
I base my dtext height off of the dimscale value. My question is how to I select all dtext on a layer to modify the (40 . 0.0937501) to
(40 . 0.375), or any new value based upon a different dimscale?

I want the routine do scale up all of the sellected dtext. I need more coffeeeeeeee

(0 . "TEXT")
(330 . <Entity name: 7ee4fcf8>)
(5 . "108")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "A-NOTE")
(100 . "AcDbText")
(10 11.3032 10.9047 0.0)
(40 . 0.0937501)
(1 . "30\" CLEARANCE MIN")
(50 . 0.0)
(41 . 0.7)
(51 . 0.0)
(7 . "NOTES")
(71 . 0)
(72 . 0)
(11 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(100 . "AcDbText")
(73 . 0)


(0 . "TEXT")
(330 . <Entity name: 7ee4fcf8>)
(5 . "10D")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "A-NOTE")
(100 . "AcDbText")
(10 11.3854 9.44752 0.0)
(40 . 0.375)
(1 . "30\" CLEARANCE MIN")
(50 . 0.0)
(41 . 0.7)
(51 . 0.0)
(7 . "NOTES")
(71 . 0)
(72 . 0)
(11 0.0 0.0 0.0)
(210 0.0 0.0 1.0)
(100 . "AcDbText")
(73 . 0)

Code: [Select]
;;my old out of date routine:
(defun STY-NOTES ();(/ sset cnt sty enam eobj wid)
  (setq XNOTES 0.7)
  (setvar "cmdecho" 0)
  ;(command "-style" ARCH#TXSN ARCH#TXFN "0" (rtos XNOTES 2 3) "0" "N" "N" "N")
  (command "-style" ARCH#TXSN ARCH#TXFN "0" (rtos XNOTES 2 3) "0" "N" "N")
  (setq SSET (ssget "X"
                    (list (cons 0 "*TEXT")
                          (cons 7 "ANNO*,HELVL,NOTE*,STANDARD")
                          (cons 8 "0,*ANNO*,*DATA*,*DIM*,*LEAD*,*NOTE*,*SYM*,*TEXT*")
                    )
             )
        CNT  0
        STY  "NOTES"
        WID  XNOTES
  )
  (vl-load-com)
  (if SSET
    (progn
      (repeat (sslength SSET)
        (setq ENAM (ssname SSET CNT)
              CNT  (1+ CNT)
              EOBJ (vlax-ename->vla-object ENAM)
        )
        (progn
          (vla-put-stylename EOBJ STY)
          (vla-put-scalefactor EOBJ WID)
        )
      )
      (princ
        "\n*        Text: Textstyle Notes completed         *"
      )
    )
  )
  (princ)
)
Title: Re: How to change texstyle of sellected dtext
Post by: ronjonp on January 03, 2011, 11:24:49 AM
Couldn't you just use entmod Gary?

(setq el (entget (car (entsel))))
(entmod (subst (cons 40 0.375) (assoc 40 el) el))
Title: Re: How to change texstyle of sellected dtext
Post by: GDF on January 03, 2011, 11:57:40 AM
Couldn't you just use entmod Gary?

(setq el (entget (car (entsel))))
(entmod (subst (cons 40 0.375) (assoc 40 el) el))

Thanks Ron

I need to change (setq el (entget (car (entsel))))  to get all of the dtext objects with that current textstyle value.
So that all of the dtext within that sellection set can be changed.
Title: Re: How to change texstyle of sellected dtext
Post by: Lee Mac on January 03, 2011, 12:13:54 PM
Maybe something like this Gary?

Code: [Select]
(defun c:test ( / ht ss i elist )
  ;; Example by Lee Mac 2011 - www.lee-mac.com

  (if
    (and
      (setq ht (getdist "\nSpecify New Text Height: "))
      (setq ss (ssget "_X" (list (cons 0 "TEXT") (cons -4 "<NOT") (cons 40 ht) (cons -4 "NOT>"))))
    )
    (repeat (setq i (sslength ss))     

      (if (setq elist (entget (ssname ss (setq i (1- i))))
                elist (entmod (subst (cons 40 ht) (assoc 40 elist) elist))
          )
        (entupd (cdr (assoc -1 elist)))
      )
    )
  )

  (princ)
)

EDIT: Noticed you also want to filter by a layer: add something like:

Code: [Select]
(cons 8 "Your Layer Here")
To the ssget filter list :-)
Title: Re: How to change texstyle of sellected dtext
Post by: trogg on January 03, 2011, 12:19:01 PM
Lee,
Is this your first posting for 2011?
meaning "did you ever take a break over the weekend?"
~Greg
Title: Re: How to change texstyle of sellected dtext
Post by: GDF on January 03, 2011, 12:20:26 PM
Thanks Lee that was what I was looking for.
I had a second cup of cooffee, and it still has not kicked in.

This is my text height value for my notes in architectural units:
(setq ht (/ (getvar "dimscale")  10.66666))

The more I learn the less I know...

Thanks again
Title: Re: How to change texstyle of sellected dtext
Post by: Lee Mac on January 03, 2011, 12:37:30 PM
Is this your first posting for 2011?
meaning "did you ever take a break over the weekend?"

lol yeah, had a small break - but you should know by now that I'm a Swamp addict  :lol:
Title: Re: How to change texstyle of sellected dtext
Post by: Lee Mac on January 03, 2011, 12:37:49 PM
Thanks Lee that was what I was looking for.
I had a second cup of cooffee, and it still has not kicked in.

This is my text height value for my notes in architectural units:
(setq ht (/ (getvar "dimscale")  10.66666))

The more I learn the less I know...

Thanks again

Cool - you all sorted now?  :-)
Title: Re: How to change texstyle of sellected dtext
Post by: GDF on January 03, 2011, 12:43:25 PM
Yes, thanks again Ron and Lee

here is my modified routine:
Code: [Select]
(defun c:test ( / ht ss i elist )
  ;; Example by Lee Mac 2011 - www.lee-mac.com
  (if
    (and
      (setq ht (/ (getvar "dimscale")  10.66666))
      (setq ss (ssget "_X" (list (cons 7 "ANNO*,HELVL,NOTE*,STANDARD")(cons 8 "0,*ANNO*,*NOTE*,*TEXT*")(cons 0 "TEXT")(cons -4 "<NOT")(cons 40 ht)(cons -4 "NOT>"))))
    )
    (repeat (setq i (sslength ss))     
      (if (setq elist (entget (ssname ss (setq i (1- i))))
                elist (entmod (subst (cons 40 ht) (assoc 40 elist) elist))
          )
        (entupd (cdr (assoc -1 elist)))
      )
    )
  )
  (if
    (and
      (setq ht (/ (getvar "dimscale")  5.33333))
      (setq ss (ssget "_X" (list (cons 7 "TITLE,HELVL,NOTE*,STANDARD")(cons 8 "0,*SHTT*,*SYMB*")(cons 0 "TEXT")(cons -4 "<NOT")(cons 40 ht)(cons -4 "NOT>"))))
    )
    (repeat (setq i (sslength ss))     
      (if (setq elist (entget (ssname ss (setq i (1- i))))
                elist (entmod (subst (cons 40 ht) (assoc 40 elist) elist))
          )
        (entupd (cdr (assoc -1 elist)))
      )
    )
  )
  (princ)
)
Title: Re: How to change texstyle of sellected dtext
Post by: ronjonp on January 03, 2011, 01:07:01 PM
I didn't do much .. but glad to help anyways  :-).

Not important but you could also shorten up your filter a bit with '(-4 . "/=")(cons 40 ht) rather than (cons -4 "<NOT")(cons 40 ht)(cons -4 "NOT>").

Ron