Author Topic: Dimension Text - Dtext or Mtext  (Read 11196 times)

0 Members and 1 Guest are viewing this topic.

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Dimension Text - Dtext or Mtext
« Reply #15 on: January 20, 2006, 05:04:24 PM »
Quote
2. What are you doing with the dimensions which have an override?

I'm going to explode them, grab the override, change it to Dtext.

Didn't you say this was a big No-No?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #16 on: January 20, 2006, 05:06:52 PM »
Yes. I'lll post em if you want to race me to see who can write this. Just kiddin. You'd leave me in your dust.
You can hold your own.

See if I have a grasp of the solution that will work.

Grab all dims
Test for overrides that contain the %%nnn from your list
Make a dimtext object out if the text
Set the over ride to ""
Place the dimtext in the same location as the override was.
Done
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #17 on: January 20, 2006, 05:10:32 PM »
Quote
2. What are you doing with the dimensions which have an override?

I'm going to explode them, grab the override, change it to Dtext.

Didn't you say this was a big No-No?

I'm treating this like an Omlette, sometimes you have to break some eggs.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #18 on: January 20, 2006, 05:12:55 PM »
Yes. I'lll post em if you want to race me to see who can write this. Just kiddin. You'd leave me in your dust.
You can hold your own.

See if I have a grasp of the solution that will work.

Grab all dims
Test for overrides that contain the %%nnn from your list
Make a dimtext object out if the text
Set the over ride to ""
Place the dimtext in the same location as the override was.
Done

Yessiree, just like Mom used to make. Mmmmm good Omlette.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #19 on: January 20, 2006, 05:14:42 PM »
I am gathering the on the ASCII codes...

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #20 on: January 20, 2006, 05:25:37 PM »
Wait a minute...

if you take your solution and do this to it, I think it'll work:

Grab all dims
Test for overrides that contain the %%nnn from your list
Explode the dimension and grab the MTEXT object
Make a dimtext DTEXT object out if the text MTEXT object
Set the over ride to ""
Place the dimtext DTEXT in the same location as the override was.
Done

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #21 on: January 20, 2006, 05:29:40 PM »
%%202 thru %%216

Starting with 1/16 incremented by 1/16 through 15/16

So %%202 = 1/16, and %%216 = 15/16

Uses Comed.shx

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Dimension Text - Dtext or Mtext
« Reply #22 on: January 20, 2006, 06:08:42 PM »
See if this works for you.  It keeps the old dims in tact.
Code: [Select]
(defun c:RewriteDimText (/ ss Ent tmpEnt EntData OldStr NumStr)

(if (setq ss (ssget "x" '((0 . "DIMENSION"))))
 (while (setq Ent (ssname ss 0))
  (setq tmpEnt (tblobjname "block" (cdr (assoc 2 (entget Ent)))))
  (while (/= (cdr (assoc 0 (setq EntData (entget (setq tmpEnt (entnext tmpEnt)))))) "MTEXT"))
  (setq OldStr (cdr (assoc 1 EntData)))
  (if (setq Pos (vl-string-search "%%2" OldStr))
   (progn
    (setq PreFix (substr OldStr 1 Pos))
    (setq Num (atoi (substr OldStr (+ 3 Pos) 3)))
    (setq Suffix (substr OldStr (+ 6 Pos)))
    (setq NumStr (rtos (* (- Num 201) 0.0625) 4 4))
    (setq OldStr (strcat PreFix (substr NumStr 1 (1- (strlen NumStr))) Suffix))
   )
  )
  (entmake
   (list
    '(0 . "TEXT")
    '(100 . "AcDbEntity")
    (cons 8 (cdr (assoc 8 EntData)))
    '(100 . "AcDbTEXT")
    (cons 10 (cdr (assoc 10 EntData)))
    (cons 40 (cdr (assoc 40 EntData)))
    (cons 1 OldStr)
    '(72 . 4)
    '(73 . 0)
    (cons 11 (cdr (assoc 10 EntData)))
   )
  )
  (ssdel Ent ss)
 )
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #23 on: January 20, 2006, 06:18:04 PM »
This what was returned:
Quote
AutoCAD menu utilities loaded.
Command: (load"rwdt")
C:RWDT

Command: rwdt
; error: bad argument type: lentityp nil

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Dimension Text - Dtext or Mtext
« Reply #24 on: January 20, 2006, 06:30:28 PM »
Did you change anything else?  On my computer it works fine.  Post back what you have, and will run it here and see what happens.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #25 on: January 20, 2006, 06:35:58 PM »
I just gave it an acronym.

Code: [Select]
(defun c:RWDT (/ ss Ent tmpEnt EntData OldStr NumStr)

(if (setq ss (ssget "x" '((0 . "DIMENSION"))))
(while (setq Ent (ssname ss 0))
  (setq tmpEnt (tblobjname "block" (cdr (assoc 2 (entget Ent)))))
  (while (/= (cdr (assoc 0 (setq EntData (entget (setq tmpEnt (entnext tmpEnt)))))) "MTEXT"))
  (setq OldStr (cdr (assoc 1 EntData)))
  (if (setq Pos (vl-string-search "%%2" OldStr))
   (progn
    (setq PreFix (substr OldStr 1 Pos))
    (setq Num (atoi (substr OldStr (+ 3 Pos) 3)))
    (setq Suffix (substr OldStr (+ 6 Pos)))
    (setq NumStr (rtos (* (- Num 201) 0.0625) 4 4))
    (setq OldStr (strcat PreFix (substr NumStr 1 (1- (strlen NumStr))) Suffix))
   )
  )
  (entmake
   (list
    '(0 . "TEXT")
    '(100 . "AcDbEntity")
    (cons 8 (cdr (assoc 8 EntData)))
    '(100 . "AcDbTEXT")
    (cons 10 (cdr (assoc 10 EntData)))
    (cons 40 (cdr (assoc 40 EntData)))
    (cons 1 OldStr)
    '(72 . 4)
    '(73 . 0)
    (cons 11 (cdr (assoc 10 EntData)))
   )
  )
  (ssdel Ent ss)
)
)
(princ)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Dimension Text - Dtext or Mtext
« Reply #26 on: January 20, 2006, 06:40:41 PM »
That is weird.  It works on mine, with no dims, with one, and with two.  Can you post a small sample drawing that is causeing the problems?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #27 on: January 20, 2006, 06:43:50 PM »
Worked for me although I added this.
Code: [Select]
(defun c:RewriteDimText (/ ss Ent tmpEnt EntData OldStr NumStr)

(if (setq ss (ssget "x" '((0 . "DIMENSION")
                           (-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
(while (setq Ent (ssname ss 0))
  (setq tmpEnt (tblobjname "block" (cdr (assoc 2 (entget Ent)))))
  (while (/= (cdr (assoc 0 (setq EntData (entget (setq tmpEnt (entnext tmpEnt)))))) "MTEXT"))
  (setq OldStr (cdr (assoc 1 EntData)))
  (if (setq Pos (vl-string-search "%%2" OldStr))
   (progn
    (setq PreFix (substr OldStr 1 Pos))
    (setq Num (atoi (substr OldStr (+ 3 Pos) 3)))
    (setq Suffix (substr OldStr (+ 6 Pos)))
    (setq NumStr (rtos (* (- Num 201) 0.0625) 4 4))
    (setq OldStr (strcat PreFix " " (substr NumStr 1 (1- (strlen NumStr))) Suffix))
   )
  )
  (entmake
   (list
    '(0 . "TEXT")
    '(100 . "AcDbEntity")
    (cons 8 (cdr (assoc 8 EntData)))
    '(100 . "AcDbTEXT")
    (cons 10 (cdr (assoc 10 EntData)))
    (cons 40 (cdr (assoc 40 EntData)))
    (cons 1 OldStr)
    '(72 . 4)
    '(73 . 0)
    (cons 11 (cdr (assoc 10 EntData)))
   )
  )
  (ssdel Ent ss)
)
)
(princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #28 on: January 20, 2006, 06:49:40 PM »
Their inlies the problem, you would need some proprietary info that I can't give to you (comed.shx).

Strange things are afoot...

When I open the drawing, the MTEXT objects are showing the ASCII chars properly, when I DDEDIT them (withoutchanging anything) they revert to raw ASCII. Hmmmm.... I've seen this before.

Will check back tomorrow, have to go fight traffic for an hour or so.

Thanks guys.

Patrick  :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Dimension Text - Dtext or Mtext
« Reply #29 on: January 20, 2006, 06:52:37 PM »
That is what I was thinking.  Maybe it's not find any mtext object in the block definition.  We can figure that out another time, tomorrow or Monday.  Hope there isn't too much traffic.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.