TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on February 02, 2010, 10:08:40 PM

Title: Underlined Mtext
Post by: MeasureUp on February 02, 2010, 10:08:40 PM
How to write underlined mtext by using lisp?
Thanks in advance.
Title: Re: Underlined Mtext
Post by: CAB on February 02, 2010, 10:15:44 PM
Perhaps the answer you seek is HERE (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MnwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8dW5kZXJsaW5lIG10ZXh0)
Title: Re: Underlined Mtext
Post by: MeasureUp on February 03, 2010, 01:14:25 AM
Perhaps the answer you seek is HERE (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MnwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8dW5kZXJsaW5lIG10ZXh0)
Thanks for your help.
Title: Re: Underlined Mtext
Post by: CAB on February 03, 2010, 08:39:44 AM
You're welcome.
Did you find the information you needed?
Title: Re: Underlined Mtext
Post by: Lee Mac on February 03, 2010, 08:59:19 AM
Code: [Select]
[color=RED]{\\L[/color]This text is Underlined[color=RED]}[/color]
Title: Re: Underlined Mtext
Post by: cmwade77 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.
Title: Re: Underlined Mtext
Post by: Joe Burke 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: Lee Mac 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))
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: Lee Mac 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?
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: Lee Mac 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))
Title: Re: Underlined Mtext
Post by: MeasureUp 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.  :-)
Title: Re: Underlined Mtext
Post by: CAB 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?
Title: Re: Underlined Mtext
Post by: Lee Mac on February 05, 2010, 11:49:47 AM
Nice one  :-)

This may help you  :-)

http://autodesk.com/techpubs/autocad/acad2000/dxf/ (http://autodesk.com/techpubs/autocad/acad2000/dxf/)
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp on February 05, 2010, 10:29:48 PM
Nice one  :-)

This may help you  :-)

http://autodesk.com/techpubs/autocad/acad2000/dxf/ (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.
Title: Re: Underlined Mtext
Post by: CAB 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)
)
Title: Re: Underlined Mtext
Post by: Kerry 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
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: Kerry 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
Title: Re: Underlined Mtext
Post by: CAB on February 06, 2010, 07:12:49 AM
Don't forget to visit this thread:
http://www.theswamp.org/index.php?topic=24700.msg359343#msg359343
Title: Re: Underlined Mtext
Post by: Lee Mac 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.
Title: Re: Underlined Mtext
Post by: MeasureUp 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.