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

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #15 on: September 24, 2009, 09:37:09 AM »
Yes, that was running what you posted  :wink:
Oh ok, were you reporting the error with the use of (entlast)?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #16 on: September 24, 2009, 09:50:23 AM »
This is what I used, and this is what I got  :wink:

Code: [Select]
(defun c:test  (/ *error* str p1 p2 txt)

  (defun *error* (e)
    (vl-bt))

  (setq str "Matt W")

  (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))))
       (command "_.mtedit" txt))

  (princ))

Code: [Select]
Command: test
Specify First Corner:
Specify Second Corner: _.mtedit Select an MTEXT object:   Application ERROR:
irfcld

Command:
Command: Backtrace:
[0.54] (VL-BT)
[1.50] (*ERROR* "invalid AutoCAD command: <Entity name: 7ef038a0>") LAP+7
[2.44] (_call-err-hook #<USUBR @12bdacbc *ERROR*> "invalid AutoCAD command:
<Entity name: 7ef038a0>")
[3.38] (sys-error "invalid AutoCAD command: <Entity name: 7ef038a0>")
:ERROR-BREAK.33 "invalid AutoCAD command: <Entity name: 7ef038a0>"
[4.30] (sys-acmd-err-hook <Entity name: 7ef038a0>)
[5.25] (ads-cmd <Entity name: 7ef038a0>)
[6.20] (C:TEST) LAP+278
[7.15] (#<SUBR @12bdacf8 -rts_top->)
[8.12] (#<SUBR @0f06a35c veval-str-body> "(C:TEST)" T #<FILE internal>)
:CALLBACK-ENTRY.6 (:CALLBACK-ENTRY)
:ARQ-SUBR-CALLBACK.3 (nil 0)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #17 on: September 24, 2009, 11:01:58 AM »
Remove the error handler & run from VLIDE, where does it stop?
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 #18 on: September 24, 2009, 11:05:39 AM »
I wonder why it crashes for you.  :?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #19 on: September 24, 2009, 11:08:04 AM »
Reading back post I see it's the editor causing or reportint the error.
My suspicion is that the mText entity is missing some dxf code that the editor is looking for.
Just a guess.
Do a dump on the new object & one with an existing mtext object to compare.

Code: [Select]
(defun c:myentget( / ent)
(and (setq ent (car (entsel "\nSelect entity to list.")))
       (setq ent (entget ent)))
  (mapcar 'print ent)
  (princ)
)
« Last Edit: September 24, 2009, 11:11:16 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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #20 on: September 24, 2009, 11:12:38 AM »
Created by Routine:

Code: [Select]
(-1 . <Entity name: 7eb4c5b8>)
(0 . "MTEXT")
(330 . <Entity name: 7ef01cf8>)
(5 . "3FC97")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbMText")
(10 31.6891 0.897154 0.0)
(40 . 2.5)
(41 . 22.1367)
(46 . 0.0)
(71 . 1)
(72 . 5)
(1 . "Matt W")
(7 . "Verdana")
(210 0.0 0.0 1.0)
(11 1.0 0.0 0.0)
(42 . 11.7915)
(43 . 2.55205)
(50 . 0.0)
(73 . 1)
(44 . 1.0)

Created by Me:

Code: [Select]
(-1 . <Entity name: 7eb4c5c0>)
(0 . "MTEXT")
(330 . <Entity name: 7ef01cf8>)
(5 . "3FC98")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "0")
(100 . "AcDbMText")
(10 -5.32893 0.897154 0.0)
(40 . 2.5)
(41 . 22.1367)
(46 . 0.0)
(71 . 1)
(72 . 5)
(1 . "Matt W")
(7 . "Verdana")
(210 0.0 0.0 1.0)
(11 1.0 0.0 0.0)
(42 . 11.7915)
(43 . 2.55205)
(50 . 0.0)
(73 . 1)
(44 . 1.0)

I used a copied rectangle to get the same MText Width.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #21 on: September 24, 2009, 11:13:55 AM »
The weird thing is, if I use MTEdit on the newly created object, after the routine has crashed - I can edit it normally..  :|

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #22 on: September 24, 2009, 11:20:24 AM »
What does this do?
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
      (vla-update (vlax-ename->vla-object txt))
      (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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Automatically add Mtext text string into Mtext editor
« Reply #23 on: September 24, 2009, 11:30:00 AM »
The weird thing is, if I use MTEdit on the newly created object, after the routine has crashed - I can edit it normally..  :|
Odd.
It can't be because you are in 2010.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #24 on: September 24, 2009, 12:38:30 PM »
I get this CAB with that code:

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

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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically add Mtext text string into Mtext editor
« Reply #25 on: September 24, 2009, 01:46:22 PM »
How about this one Lee, then dump the object again after mtext will edit it.
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
      (vlax-dump-object (vlax-ename->vla-object txt) t)
      (command "_.mtedit" txt)
    )
  )
  (princ)
)
« Last Edit: September 24, 2009, 01:49:38 PM 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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #26 on: September 24, 2009, 01:53:16 PM »
Dump provided by code:

Code: [Select]
Command: test
Specify First Corner:
Specify Second Corner: ; IAcadMText: AutoCAD MText Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 009791b4>
;   AttachmentPoint = 1
;   BackgroundFill = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0efa6ab0>
;   DrawingDirection = 5
;   Handle (RO) = "23FC0"
;   HasExtensionDictionary (RO) = 0
;   Height = 2.5
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0f2eef9c>
;   InsertionPoint = (1.87874 1.41485 0.0)
;   Layer = "0"
;   LineSpacingDistance = 4.16667
;   LineSpacingFactor = 1.0
;   LineSpacingStyle = 1
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2128006592
;   ObjectName (RO) = "AcDbMText"
;   OwnerID (RO) = 2129665272
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   StyleName = "Verdana"
;   TextString = "Matt W"
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 1c13da70>
;   Visible = -1
;   Width = 1.55443
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   FieldCode ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (_.mtedit Select an MTEXT object:   Application ERROR: irfcld

Command:
Command: 2)
;   TransformBy (1)
;   Update ()
; error: invalid AutoCAD command: <Entity name: 7ed6cdc0>

Dump After running code:

Code: [Select]
Command: dump
Select entity to get object data:
; IAcadMText: AutoCAD MText Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 009791b4>
;   AttachmentPoint = 1
;   BackgroundFill = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0efa6ab0>
;   DrawingDirection = 5
;   Handle (RO) = "23FC0"
;   HasExtensionDictionary (RO) = 0
;   Height = 2.5
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 19d6abcc>
;   InsertionPoint = (1.87874 1.41485 0.0)
;   Layer = "0"
;   LineSpacingDistance = 4.16667
;   LineSpacingFactor = 1.0
;   LineSpacingStyle = 1
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2128006592
;   ObjectName (RO) = "AcDbMText"
;   OwnerID (RO) = 2129665272
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   StyleName = "Verdana"
;   TextString = "Matt W"
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 1c13db60>
;   Visible = -1
;   Width = 1.55443
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   FieldCode ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Automatically add Mtext text string into Mtext editor
« Reply #27 on: September 24, 2009, 02:14:07 PM »
Works here in both '06 and '09.  Sorry.  Don't know what it could be Lee.
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: Automatically add Mtext text string into Mtext editor
« Reply #28 on: September 24, 2009, 02:16:21 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?


« Last Edit: September 24, 2009, 02:23:38 PM 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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Automatically add Mtext text string into Mtext editor
« Reply #29 on: September 24, 2009, 06:08:24 PM »
This is the only other reference to that error that I could find, but even they don't know what it is...