Author Topic: Automatically add Mtext text string into Mtext editor  (Read 12378 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #30 on: September 24, 2009, 06:10:12 PM »
What's up with this?
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 1c13da70>          ;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 1c13db60>

The color is different! Is the first an invalid color?


The TrueColor object number is always a different hex I think.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #31 on: September 24, 2009, 07:01:43 PM »
Test this:
Code: [Select]
(defun c:test (/ str p1 p2 txt)
  (setq str "Matt W")
  (if (and (setq p1 (getpoint "\nSpecify First Corner: "))
           (setq p2 (getcorner p1 "\nSpecify Second Corner: "))
           (setq txt (entmakex
                       (list
                         (cons 0 "MTEXT")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbMText")
                         (cons 10 p1)
                         (cons 40 (getvar "TEXTSIZE"))
                         (cons 41 (abs (- (car p2) (car p1))))
                         (cons 7 (getvar "TEXTSTYLE"))
                         (cons 1 str)
                       )
                     )
           )
      )
      (mtedit txt)
  )
  (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.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #32 on: September 24, 2009, 07:05:17 PM »
Thanks for your effort Alan, but I get:

Quote
Command:
Command: test

Specify First Corner:
Specify Second Corner: ; error: no function definition: MTEDIT

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #33 on: September 24, 2009, 07:11:15 PM »
(mtedit txt)
How'd you find this one?!?!?!!

Test this:
Code: [Select]
(defun c:test (/ str p1 p2 txt)
  (setq str "Matt W")
  (if (and (setq p1 (getpoint "\nSpecify First Corner: "))
           (setq p2 (getcorner p1 "\nSpecify Second Corner: "))
           (setq txt (entmakex
                       (list
                         (cons 0 "MTEXT")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbMText")
                         (cons 10 p1)
                         (cons 40 (getvar "TEXTSIZE"))
                         (cons 41 (abs (- (car p2) (car p1))))
                         (cons 7 (getvar "TEXTSTYLE"))
                         (cons 1 str)
                       )
                     )
           )
      )
      (mtedit txt)
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #34 on: September 24, 2009, 07:15:32 PM »
That's a secrete.  8-)
Typing the command in VLIDE you will see valid lisp calls when they turn blue.
You have to figure out what the arguments are though.  :evil:
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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #35 on: September 24, 2009, 07:16:58 PM »
I would say it's an arx that isn't loaded, but once you mtedit something, it would work.

Thanks for your effort Alan, but I get:

Quote
Command:
Command: test

Specify First Corner:
Specify Second Corner: ; error: no function definition: MTEDIT
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #36 on: September 24, 2009, 08:05:31 PM »
That's a secrete.  8-)
Typing the command in VLIDE you will see valid lisp calls when they turn blue.
You have to figure out what the arguments are though.  :evil:
Well that's not fare. :cry: :cry:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #37 on: September 24, 2009, 08:10:48 PM »
Maybe this?
Code: [Select]
(defun c:test (/ str p1 p2 txt)
  (setq str "Matt W")
  (if (and (setq p1 (getpoint "\nSpecify First Corner: "))
           (setq p2 (getcorner p1 "\nSpecify Second Corner: "))
           (setq txt (entmakex
                       (list
                         (cons 0 "MTEXT")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbMText")
                         (cons 10 p1)
                         (cons 40 (getvar "TEXTSIZE"))
                         (cons 41 (abs (- (car p2) (car p1))))
                         (cons 7 (getvar "TEXTSTYLE"))
                         (cons 1 str)
                       )
                     )
           )
      )
    (progn
      (command ".mtedit") (command)
      (command ".mtedit" txt)
    )
  )
  (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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #38 on: September 24, 2009, 09:12:43 PM »
Alan, here is a helper.
Code: [Select]
    (defun GetAtoms (pattern)
        (setq pattern (strcase pattern))
        (vl-remove-if-not
            '(lambda (name) (wcmatch  name pattern))
            (atoms-family 1)
        )
    )

_$ (getAtoms "mt*")
("MTPROP" "MTEDIT")
_$
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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #39 on: September 24, 2009, 09:20:25 PM »
LoL
I was actually looking at it with almost the same method. Thanks Alan. :-)

Alan, here is a helper.
Code: [Select]
    (defun GetAtoms (pattern)
        (setq pattern (strcase pattern))
        (vl-remove-if-not
            '(lambda (name) (wcmatch  name pattern))
            (atoms-family 1)
        )
    )

_$ (getAtoms "mt*")
("MTPROP" "MTEDIT")
_$
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #40 on: September 25, 2009, 06:28:59 AM »
Alan, the "mtedit" does not appear blue in my VLIDE...  :|  I tried (vl-arx-import 'mtedit) and still nothing  :|

I tried your most recent code and received this:

Quote
Command: test
Specify First Corner:
Specify Second Corner: .mtedit Select an MTEXT object:
Command: .mtedit Select an MTEXT object:   Application ERROR: irfcld

Command:
Command: ; error: invalid AutoCAD command: <Entity name: 7ef03698>

Could it be that I am using a Student Version?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #41 on: September 25, 2009, 08:30:26 AM »
For what ever reason your Mtext command is different from ours    :ugly:
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.