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

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
Dimension Text - Dtext or Mtext
« on: January 20, 2006, 12:15:46 PM »
I am looking for a way to convert dimension text to DTEXT in AutoCAD '02. I've looked for an hour now, and I haven't found diddly on this subject anywhere (Swamp, Help Files, Google).

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Dimension Text - Dtext or Mtext
« Reply #1 on: January 20, 2006, 12:19:32 PM »
Can't you explode the dimensions?

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #2 on: January 20, 2006, 12:34:53 PM »
Can't you explode the dimensions?

That is a BIG NO-NO!

hudster

  • Gator
  • Posts: 2848
Re: Dimension Text - Dtext or Mtext
« Reply #3 on: January 20, 2006, 12:46:25 PM »
copy, paste? :wink:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Chuck Gabriel

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #4 on: January 20, 2006, 12:55:34 PM »
Are you saying you want to make associative dimensions use text instead of mtext for the dimension text?

If you are, I'm gonna say you can't do that.

However, I assume you want to do that because you don't like the mtext editor.  If so, try changing the value of the MTEXTED system variable to :lisped.

M-dub

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #5 on: January 20, 2006, 12:58:36 PM »
Is there an express tool that does that?  I'm back in our office (not where I usually am) so I can't tell.  We don't have Express Tools :roll:

Having another look.....

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
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 #7 on: January 20, 2006, 01:44:52 PM »
Are you saying you want to make associative dimensions use text instead of mtext for the dimension text?

If you are, I'm gonna say you can't do that.

However, I assume you want to do that because you don't like the mtext editor. If so, try changing the value of the MTEXTED system variable to :lisped.

Reason:
We have a client that uses a font with "Special ASCII Characters" (%%130 = Delta Symbol, etc.) and they don't work with Mtext. Alot of their drawings are R14 and below, so to preserve their DIMENSION fractions without having to change a million I was (hoping) that their was some easy fix. I am sorley mistaken. Ugh.

Thanks for the responses.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Dimension Text - Dtext or Mtext
« Reply #8 on: January 20, 2006, 02:14:39 PM »
Can't you use Unicodes?

%%130 -> \U+0082
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #9 on: January 20, 2006, 02:23:05 PM »
When you say "dimension text" are you just going after the dimension override?
Or are you looking to combine the override with the dimension?
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 #10 on: January 20, 2006, 03:01:12 PM »
When you say "dimension text" are you just going after the dimension override?
Or are you looking to combine the override with the dimension?

Just the override. I'm trying to steer away from having to modify a whole drawing, entity by entity. I'll explain in detail (keep in mind I'm typing this in between waiting for Mickeystation/Projectwise drawings to open/close as I have a rush job at the moment and will be working all W.E.).

In suspect drawing, all dimensions with fractions use special ASCII Chars. for fractions (R14 and below dwgs) and they are all overrides. This means that in, say a structural drawing there will be about 50 or so dimensions with text that looks like 9'-3%%206". When I explode the dimension and then the text, the text breaks into 2 entities, leaving one 9'-3 and a separate fraction entity. This is causing me extreme grief. If I could globally change all dimension text to DTEXT, my life would get a little easier. Carol Bartz will be getting a letter, and I will be adjusting her scorcard pending the outcome.

Clear as mud?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #11 on: January 20, 2006, 03:13:21 PM »
Why not remove all the over rides?
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 #12 on: January 20, 2006, 03:33:38 PM »
Why not remove all the over rides?

Two reasons:

1. The drafter/'s did not draw to the dimensions (NTS).
2. Standards dictate that fractions must be as defined in the ASCII chars. which are small slanted fractions (I'd post a pic, but pressed for time at the moment).


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #13 on: January 20, 2006, 04:07:02 PM »
OK,
1. What do you want dtext of the dimension override for?
2. What are you doing with the dimensions which have an override?
3. Do you have a list if the characters codes that represent the fractions?

In other words are you translating the dimtext to be placed in dtext?
Or are you translating from one text style special characters to a second text style
with special characters. And if so are you updating the dim override or creating new dtext?
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 #14 on: January 20, 2006, 04:52:51 PM »
Chuck,

Quote
1. What do you want dtext of the dimension override for?

The only way to show the special characters properly is in Dtext, Mtext just shows the raw ASCII.

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.

Quote
3. Do you have a list if the characters codes that represent the fractions?

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. I must leave the text styles as is. The client uses a modified "Standard".

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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Dimension Text - Dtext or Mtext
« Reply #30 on: January 20, 2006, 07:10:09 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>"))))
<snip>
That is a good add.  I don't use the "-4"s at all with ssget.  I guess I should learn that one one of these days.
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 #31 on: January 20, 2006, 08:32:31 PM »
Thanks Tim,

Well this is as far as I got, fighting the flu, so maybe tomorrow.
Did not know how to get the actual rotation of the dimension line.

Code: [Select]
(defun c:fixdims ()
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (and (or (ssget '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))
           (ssget "X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
       (setq ss (vla-get-activeselectionset
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
       ) ;use ActiveX ss
       (setq mspace (vla-get-modelspace
  (vla-get-activedocument
(vlax-get-acad-object)
)
  ))
       (vlax-for x ss
         (if (vl-string-search "%%2" (setq str (vla-get-textoverride x)))
          (progn
            (vlax-dump-object x T)
            (if (setq newobj (vla-addtext mspace str (vla-get-textPosition x) (vla-get-textheight x)))
              (progn
                (vlax-put-property newobj 'Alignment  acAlignmentMiddleCenter)
                (vla-put-textAlignmentPoint newobj (vla-get-TextPosition x))
                ;;(vla-put-Rotation newobj (vla-get-Rotation x))
                (vla-put-StyleName newobj  (vla-get-TextStyle x))
                (vla-put-Height newobj  (* (vla-get-ScaleFactor x)(vla-get-TextHeight x)))
                (vla-put-Layer newobj  (vla-get-Layer x))
                (vla-put-Color newobj  (vla-get-TextColor x))
 
                (vla-put-textoverride x " ")
                (vlax-release-object newobj)
              )
              (prompt (strcat "\nERROR replacong dimtext " str))
            )
          )
         )
       )
       (vlax-release-object mspace)
  )
  (vla-endundomark doc)
  (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.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Dimension Text - Dtext or Mtext
« Reply #32 on: January 20, 2006, 09:37:41 PM »
Just to throw out another idea......

Why not just change the "%%XXX" to be the actual symbol? To get MTEXT to display the character defined as 202, in the editor hold down the ALT key while typing 0202 on the numeric keypad. This works in lisp, too. Just set up a (cond) based on the value of "%%XXX" and set it to the corresponding ASCII value......it will display differently based on which font is used, just as it does now.....and there's no messing with exploding blocks and getting a TEXT object to appear exactly as the MTEXT object did.

Aw heck, here's my stab at it...note that I do not have a drawing to test this on.....so as MP would say: YMMV ;-)

Code: [Select]
(defun c:FixDimText (/ ss Ent obj txt pos code new)
  (if (setq ss (ssget "x" '((0 . "DIMENSION")(-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
    (while (setq Ent (ssname ss 0))
      (setq obj (vlax-ename->vla-object ent)
    txt (vla-get-textoverride obj))
      (if (wcmatch txt "*%%###*")
(progn
  (setq pos (vl-string-search "%%" txt))
  (setq code (atoi (substr (substr txt (+ 3 pos)) 1 3)))
  (cond ((= code 202)(setq val "Ê"))
((= code 203)(setq val "Ë"))
((= code 204)(setq val "Ì"))
((= code 205)(setq val "Í"))
((= code 206)(setq val "Î"))
((= code 207)(setq val "Ï"))
((= code 208)(setq val "Ð"))
((= code 209)(setq val "Ñ"))
((= code 210)(setq val "Ò"))
((= code 211)(setq val "Ó"))
((= code 212)(setq val "Ô"))
((= code 213)(setq val "Õ"))
((= code 214)(setq val "Ö"))
((= code 215)(setq val "×"))
((= code 216)(setq val "Ø"))
)
  (setq new (vl-string-subst val (strcat "%%" (itoa code)) txt))
  (vla-put-textoverride obj new)
  )
)
        (ssdel ent ss) ; CAB added
      )
    )
  (princ)
  )
« Last Edit: January 20, 2006, 10:10:28 PM by CAB »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #33 on: January 20, 2006, 10:05:45 PM »
Party pooper. :-D
Just kidding Jeff, nice solution.

Here is my last attempt tonight.
The problem with the dimension angle has been approached by using dxf codes 10 & 11
But when the extension lines are not equal length this angle is incorrect.
There must be a better solution somewhere.

Code: [Select]
(defun c:fixdims (/ doc elst mspace newobj ss str)
 
  (defun get_angle (obj / ang)
    (setq elst (entget (vlax-vla-object->ename obj)))
    (setq ang (angle (cdr (assoc 10 elst)) (cdr (assoc 11 elst))))
    (cond
      ((and (> ang (/ pi 2)) (<= ang pi))
       (setq ang (+ ang pi))
      )
      ((and (> ang pi) (< ang (* pi 1.5)))
       (setq ang (- ang pi))
      )
    )
  )


  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (and (or (ssget '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))
           (ssget "X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))
       )
       (setq ss (vla-get-activeselectionset doc)
       ) ;use ActiveX ss
       (setq mspace (vla-get-modelspace doc))
       (vlax-for x ss
         (if (vl-string-search "%%2" (setq str (vla-get-textoverride x)))
           (progn
             (vlax-dump-object x t)
             (if (setq newobj (vla-addtext mspace str (vla-get-textposition x) (vla-get-textheight x)))
               (progn
                 (vlax-put-property newobj 'alignment acalignmentmiddlecenter)
                 (vla-put-textalignmentpoint newobj (vla-get-textposition x))
                 (vla-put-stylename newobj (vla-get-textstyle x))
                 (vla-put-height newobj (* (vla-get-scalefactor x) (vla-get-textheight x)))
                 (vla-put-layer newobj (vla-get-layer x))
                 (vla-put-color newobj (vla-get-textcolor x))
                 (vla-put-rotation newobj (get_angle x))
                 (vla-put-textoverride x " ")
                 (vlax-release-object newobj)
               )
               (prompt (strcat "\nERROR replaceing dimtext " str))
             )
           )
         )
       )
       (vlax-release-object mspace)
  )
  (vla-endundomark doc)
  (princ)
)
« Last Edit: January 21, 2006, 08:25:05 AM by CAB »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #34 on: January 20, 2006, 10:11:28 PM »
Jeff,
Nice job I added one line of code and it worked perfectly.  :-)
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.

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Dimension Text - Dtext or Mtext
« Reply #35 on: January 20, 2006, 10:59:52 PM »
Thanks, Alan....that's what happens when I start my code with code I ganked from someone else's (namely, Tim's first posting)....I never use that method of going through the selection set, and I know that he does, I dunno why I didn't catch that.  :oops:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimension Text - Dtext or Mtext
« Reply #36 on: January 20, 2006, 11:51:30 PM »
No problem.

Looking ay the code.
You could go directly to the substitution with chr.

Code: [Select]
(defun c:FixDimText (/ ss Ent obj txt pos code new)
  (if (setq ss (ssget "x" '((0 . "DIMENSION")(-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
    (while (setq Ent (ssname ss 0))
      (setq obj (vlax-ename->vla-object ent)
    txt (vla-get-textoverride obj))
      (if (wcmatch txt "*%%###*")
(progn
  (setq pos (vl-string-search "%%" txt))
  (setq new (vl-string-subst (chr (atoi (substr txt (+ 3 pos) 3)))
                                     (substr txt (+ 1 pos) 5) txt))
  (vla-put-textoverride obj new)
  )
)
        (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.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Dimension Text - Dtext or Mtext
« Reply #37 on: January 21, 2006, 02:13:00 AM »
Can't you use Unicodes?

%%130 -> \U+0082
I was thinking of something like this:
Code: [Select]
(defun c:FixDimText (/ ss Ent obj txt pos code new dec2hex)
(defun dec2hex (value / num n1 n2 L)
(setq num (atoi value))
(setq L '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"))
(setq n2 (- num (* (setq n1 (/ num 16)) 16)))
(setq value (strcat (nth n1 L)(nth n2 L)))
)

(if (setq ss (ssget "x" '((0 . "DIMENSION")(-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
(while (setq Ent (ssname ss 0))
(setq obj (vlax-ename->vla-object ent)
txt (vla-get-textoverride obj))
(if (wcmatch txt "*%%###*")
  (progn
(setq pos (vl-string-search "%%" txt))
(setq new (vl-string-subst (strcat "\\U+00" (dec2hex (substr txt (+ 3 pos) 3)))
                           (substr txt (1+ pos) 5) txt))
(vla-put-textoverride obj new)
  )
)
(ssdel ent ss)
)
)
(princ)
)
(Not tested)
Vault Professional 2023     +     AEC Collection

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #38 on: January 21, 2006, 10:46:56 AM »
Quote
Well this is as far as I got, fighting the flu, so maybe tomorrow.
Did not know how to get the actual rotation of the dimension line.

I hope you didn't sneeze on the code I copied.  :-D Get better Mr. B.

Actually you guys ROCK! I didn't expect a call to arms such as this. I've got TONS of work to do, no time right now to test these, so it'll be on the back burner 'til Monday or possibly later today. Thankyou for the help.

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #39 on: January 23, 2006, 04:27:28 PM »
Can't you use Unicodes?

%%130 -> \U+0082

These seem to work, how do I get the conversions?

deegeecees

  • Guest
Re: Dimension Text - Dtext or Mtext
« Reply #40 on: January 23, 2006, 04:32:21 PM »
Just to throw out another idea......

Why not just change the "%%XXX" to be the actual symbol? To get MTEXT to display the character defined as 202, in the editor hold down the ALT key while typing 0202 on the numeric keypad. This works in lisp, too. Just set up a (cond) based on the value of "%%XXX" and set it to the corresponding ASCII value......it will display differently based on which font is used, just as it does now.....and there's no messing with exploding blocks and getting a TEXT object to appear exactly as the MTEXT object did.

Aw heck, here's my stab at it...note that I do not have a drawing to test this on.....so as MP would say: YMMV ;-)

Code: [Select]
(defun c:FixDimText (/ ss Ent obj txt pos code new)
  (if (setq ss (ssget "x" '((0 . "DIMENSION")(-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
    (while (setq Ent (ssname ss 0))
      (setq obj (vlax-ename->vla-object ent)
    txt (vla-get-textoverride obj))
      (if (wcmatch txt "*%%###*")
(progn
  (setq pos (vl-string-search "%%" txt))
  (setq code (atoi (substr (substr txt (+ 3 pos)) 1 3)))
  (cond ((= code 202)(setq val "Ê"))
((= code 203)(setq val "Ë"))
((= code 204)(setq val "Ì"))
((= code 205)(setq val "Í"))
((= code 206)(setq val "Î"))
((= code 207)(setq val "Ï"))
((= code 208)(setq val "Ð"))
((= code 209)(setq val "Ñ"))
((= code 210)(setq val "Ò"))
((= code 211)(setq val "Ó"))
((= code 212)(setq val "Ô"))
((= code 213)(setq val "Õ"))
((= code 214)(setq val "Ö"))
((= code 215)(setq val "×"))
((= code 216)(setq val "Ø"))
)
  (setq new (vl-string-subst val (strcat "%%" (itoa code)) txt))
  (vla-put-textoverride obj new)
  )
)
 (ssdel ent ss) ; CAB added
      )
    )
  (princ)
  )

This worked like a charm! Thanks again everybody.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Dimension Text - Dtext or Mtext
« Reply #41 on: January 23, 2006, 08:30:32 PM »
Can't you use Unicodes?

%%130 -> \U+0082

These seem to work, how do I get the conversions?
Convert the decimal value to hexadecimal.

Tip: Use CALC (windows calculator on scientific) to convert on the fly.
Vault Professional 2023     +     AEC Collection