Author Topic: Underlined Mtext  (Read 8989 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Underlined Mtext
« on: February 02, 2010, 10:08:40 PM »
How to write underlined mtext by using lisp?
Thanks in advance.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Underlined Mtext
« Reply #1 on: February 02, 2010, 10:15:44 PM »
Perhaps the answer you seek is HERE
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.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #2 on: February 03, 2010, 01:14:25 AM »
Perhaps the answer you seek is HERE
Thanks for your help.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Underlined Mtext
« Reply #3 on: February 03, 2010, 08:39:44 AM »
You're welcome.
Did you find the information you needed?
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.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #4 on: February 03, 2010, 08:59:19 AM »
Code: [Select]
[color=RED]{\\L[/color]This text is Underlined[color=RED]}[/color]

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Underlined Mtext
« Reply #5 on: February 03, 2010, 01:48:13 PM »
Simply add \\u to the text string, let's say your text is in a variable called TEXT
(setq TEXT (strcat "\\u" TEXT))
should do the trick.

Joe Burke

  • Guest
Re: Underlined Mtext
« Reply #6 on: February 04, 2010, 07:39:34 AM »
To underdline a text object add %%u.

But the question was how to underline an mtext object.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #7 on: February 04, 2010, 06:08:30 PM »
Code: [Select]
[color=RED]{\\L[/color]This text is Underlined[color=RED]}[/color]

Simply add \\u to the text string, let's say your text is in a variable called TEXT
(setq TEXT (strcat "\\u" TEXT))
should do the trick.

Unlike underlining TEXT, the prefix "\\L" doesn't do the trick for MTEXT.
Thanks.
« Last Edit: February 04, 2010, 06:12:01 PM by MeasureUp »

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #8 on: February 04, 2010, 06:13:19 PM »
To underdline a text object add %%u.

But the question was how to underline an mtext object.

Yes, you know what I mean.
Thanks.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #9 on: February 04, 2010, 06:13:27 PM »
Seems to work for me  :?

Code: [Select]
(defun c:MakeThatMTextUnderlined (/ ent obj)
  (vl-load-com)

  (if (and (setq ent (car (entsel "\nSelect MText: ")))
           (eq "MTEXT" (cdr (assoc 0 (entget ent)))))

    (vlax-put-property
      (setq obj (vlax-ename->vla-object ent)) 'TextString
        (strcat "{\\L"
          (vlax-get-property obj 'TextString) "}")))

  (princ))

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #10 on: February 04, 2010, 06:22:24 PM »
You're welcome.
Did you find the information you needed?


Hi CAB,
Yes, I have read ervery threads which you linked.
They are helpful. Thanks.
Another question raised after reading the info you linked:
How to customise a mtext in leader?
For example, write an underline mtext and/or set up text style in leader.
Thanks again.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #11 on: February 04, 2010, 06:26:42 PM »
Seems to work for me  :?

Code: [Select]
(defun c:MakeThatMTextUnderlined (/ ent obj)
  (vl-load-com)

  (if (and (setq ent (car (entsel "\nSelect MText: ")))
           (eq "MTEXT" (cdr (assoc 0 (entget ent)))))

    (vlax-put-property
      (setq obj (vlax-ename->vla-object ent)) 'TextString
        (strcat "{\\L"
          (vlax-get-property obj 'TextString) "}")))

  (princ))

Thank you very much.
This is very nice when underlining an existing MTEXT.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #12 on: February 04, 2010, 06:29:43 PM »
Seems to work for me  :?

Code: [Select]
(defun c:MakeThatMTextUnderlined (/ ent obj)
  (vl-load-com)

  (if (and (setq ent (car (entsel "\nSelect MText: ")))
           (eq "MTEXT" (cdr (assoc 0 (entget ent)))))

    (vlax-put-property
      (setq obj (vlax-ename->vla-object ent)) 'TextString
        (strcat "{\\L"
          (vlax-get-property obj 'TextString) "}")))

  (princ))

Thank you very much.
This is very nice when underlining an existing MTEXT.


Is that what you were after? Or was it something else?

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #13 on: February 04, 2010, 06:36:55 PM »
Seems to work for me  :?

Code: [Select]
(defun c:MakeThatMTextUnderlined (/ ent obj)
  (vl-load-com)

  (if (and (setq ent (car (entsel "\nSelect MText: ")))
           (eq "MTEXT" (cdr (assoc 0 (entget ent)))))

    (vlax-put-property
      (setq obj (vlax-ename->vla-object ent)) 'TextString
        (strcat "{\\L"
          (vlax-get-property obj 'TextString) "}")))

  (princ))

Thank you very much.
This is very nice when underlining an existing MTEXT.


Is that what you were after? Or was it something else?

Origenally, I want to write underlined MTEXT by using AutoLisp.
Thanks again.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #14 on: February 04, 2010, 07:47:48 PM »
Origenally, I want to write underlined MTEXT by using AutoLisp.
Thanks again.

Code: [Select]
(defun c:test (/ M-Text pt str)

  (defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    (cons 1 val))))

  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))

  (princ))

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #15 on: February 04, 2010, 11:27:34 PM »
Origenally, I want to write underlined MTEXT by using AutoLisp.
Thanks again.

Code: [Select]
(defun c:test (/ M-Text pt str)

  (defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    [color=red](cons 7 "ROMANS")[/color]
                    (cons 1 val))))

  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))

  (princ))

Thank you very much.
By learning your code, I read DXF section in the HELP & add a line the your code allowing to change the text style.  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Underlined Mtext
« Reply #16 on: February 04, 2010, 11:45:21 PM »
good job.
You can also set the layer and if needed the color override.
Do you see which DXF codes do that?
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.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #17 on: February 05, 2010, 11:49:47 AM »

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #18 on: February 05, 2010, 10:27:25 PM »
good job.
You can also set the layer and if needed the color override.
Do you see which DXF codes do that?


Not sure if the following correct:

Code: [Select]
(defun c:test (/ M-Text pt str)
(defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    (cons 7 "ROMANS")
                    (cons 1 val))
    ); end of entmakex
    [color=red](entmakex (list (cons 0 "LAYER")
  (cons 2 "Layer_Mtext")) ; set mtext's layer to "Layer_Mtext" if it exists.
    ); end of entmakex[/color]
)
  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))
(princ)
)

Thanks.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #19 on: February 05, 2010, 10:29:48 PM »
Nice one  :-)

This may help you  :-)

http://autodesk.com/techpubs/autocad/acad2000/dxf/

Thanks for the link.
PS. Is there a 2010 version available in autodesk's web?
I can find it there.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Underlined Mtext
« Reply #20 on: February 05, 2010, 11:18:08 PM »
Not quite. The benefit of using entmake is that if the layer does not exist it will create it without your help.

Try this:
Code: [Select]
(defun c:test (/ M-Text pt str)
(defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    (cons 7 "ROMANS")
                    (cons 8 "Layer_Mtext")
                    (cons 1 val))
    ); end of entmakex

  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))
(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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Underlined Mtext
« Reply #21 on: February 05, 2010, 11:30:32 PM »

Thanks for the link.
PS. Is there a 2010 version available in autodesk's web?
I can find it there.

Try this :-

http://images.autodesk.com/adsk/files/acad_dxf1.pdf
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #22 on: February 06, 2010, 01:21:25 AM »
Not quite. The benefit of using entmake is that if the layer does not exist it will create it without your help.

Try this:
Code: [Select]
(defun c:test (/ M-Text pt str)
(defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    (cons 7 "ROMANS")
                    (cons 8 "Layer_Mtext")
                    (cons 1 val))
    ); end of entmakex

  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))
(princ)
)

Sorry, I confuse with the DXF group codes.
I use the (cons 2 "Layer_Mtext") because I found "2" under the layer section.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #23 on: February 06, 2010, 01:28:56 AM »

Thanks for the link.
PS. Is there a 2010 version available in autodesk's web?
I can find it there.

Try this :-

http://images.autodesk.com/adsk/files/acad_dxf1.pdf

Thanks for your help. I opened the file.
I am trying to get more resources from Autodesk web.
I did a search again but can't find a page in the Autodesk web showing the entry to the DXF Reference file.
Can you show me the page?
Thanks again.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Underlined Mtext
« Reply #24 on: February 06, 2010, 02:09:49 AM »


http://usa.autodesk.com/adsk/servlet/ps/item?siteID=123112&id=2882295&linkID=9240617

Have you tried your local Help files ?  :-

C:\Program Files\Autodesk\ACAD 2010\Help\acad_dxf.chm
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Underlined Mtext
« Reply #25 on: February 06, 2010, 07:12:49 AM »
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.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Underlined Mtext
« Reply #26 on: February 06, 2010, 08:39:27 AM »
Not quite. The benefit of using entmake is that if the layer does not exist it will create it without your help.

Try this:
Code: [Select]
(defun c:test (/ M-Text pt str)
(defun M-Text (pt val)
    (entmakex (list (cons 0 "MTEXT")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbMText")
                    (cons 10 pt)
                    (cons 7 "ROMANS")
                    (cons 8 "Layer_Mtext")
                    (cons 1 val))
    ); end of entmakex

  (if (setq pt (getpoint "\nSpecify Point: "))
    (progn
      (setq str (getstring t "\nSpecify Text: "))

      (M-Text pt (strcat "{\\L" str "}"))))
(princ)
)

Sorry, I confuse with the DXF group codes.
I use the (cons 2 "Layer_Mtext") because I found "2" under the layer section.

When aiming to modify/set the properties for an entity, just look at the entity dxf group codes - these are all that you need. The layer dxf codes would be used to create/modify a layer.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #27 on: February 08, 2010, 06:23:31 PM »


http://usa.autodesk.com/adsk/servlet/ps/item?siteID=123112&id=2882295&linkID=9240617

Have you tried your local Help files ?  :-

C:\Program Files\Autodesk\ACAD 2010\Help\acad_dxf.chm

Thanks.
Yes, I know the local built in one but was thinking it would be helpful if there is one in pdf form.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #28 on: February 08, 2010, 06:26:17 PM »
Don't forget to visit this thread:
http://www.theswamp.org/index.php?topic=24700.msg359343#msg359343
You are the biggggggg man.
Thanks for the useful/helpful resources.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Underlined Mtext
« Reply #29 on: February 08, 2010, 06:29:02 PM »
...
When aiming to modify/set the properties for an entity, just look at the entity dxf group codes - these are all that you need. The layer dxf codes would be used to create/modify a layer.

Thanks. you are right.