Author Topic: How to tell mtext character width?  (Read 3435 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
How to tell mtext character width?
« on: July 15, 2009, 11:33:50 AM »
So while working on my explode mtext function, and some real world mtext text, I came across an entity where the width of the character were different than 1.0, and I don't see how that is from the code returned.

Code: [Select]
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
;   AttachmentPoint = 1
;   BackgroundFill = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 05e797c4>
;   DrawingDirection = 5
;   Handle (RO) = "EBBE9"
;   HasExtensionDictionary (RO) = 0
;   Height = 0.09375
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 15b98db4>
;   InsertionPoint = (43.5971 22.7282 0.0)
;   Layer = "HTEXT"
;   LineSpacingDistance = 0.15625
;   LineSpacingFactor = 1.0
;   LineSpacingStyle = 1
;   Linetype = "BYLAYER"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2125892744
;   ObjectName (RO) = "AcDbMText"
;   OwnerID (RO) = 2127772840
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   StyleName = "romans"
;   TextString = "testing"
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 15b98c10>
;   Visible = -1
;   Width = 3.73509
Code: [Select]
(-1 . <Entity name: 7eb68c88>)
(0 . "MTEXT")
(330 . <Entity name: 7ed33ca8>)
(5 . "EBBE9")
(100 . "AcDbEntity")
(67 . 1)
(410 . "Layout1")
(8 . "HTEXT")
(100 . "AcDbMText")
(10 43.5971 22.7282 0.0)
(40 . 0.09375)
(41 . 3.73509)
(71 . 1)
(72 . 5)
(1 . "testing")
(7 . "romans")
(210 0.0 0.0 1.0)
(11 1.0 0.0 0.0)
(42 . 0.331473)
(43 . 0.125)
(50 . 0.0)
(73 . 1)
(44 . 1.0)

Now if you explode it with the command, you can see that there is a width factor scaling it, but can't find it with the mtext properties or dxf data.
Code: [Select]
;   Alignment = 0
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
;   Backward = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 05e797c4>
;   Handle (RO) = "EBBEA"
;   HasExtensionDictionary (RO) = 0
;   Height = 0.09375
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 15ba5b14>
;   InsertionPoint = (43.5904 22.6344 0.0)
;   Layer = "HTEXT"
;   Linetype = "BYLAYER"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2125892752
;   ObjectName (RO) = "AcDbText"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 2127772840
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
[color=red];   ScaleFactor = 0.75[/color]
;   StyleName = "romans"
;   TextAlignmentPoint = (0.0 0.0 0.0)
;   TextGenerationFlag = 0
;   TextString = "testing"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 15ba5c00>
;   UpsideDown = 0
;   Visible = -1

My question is, how can one find that information for the mtext entity?

On a side note:  I found out that you can't change the size of text in code tags.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: How to tell mtext character width?
« Reply #1 on: July 15, 2009, 11:51:06 AM »
I get this when I change the character width:

Code: [Select]
;   TextString = "{\\W1.5;Lee Mac}"

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to tell mtext character width?
« Reply #2 on: July 15, 2009, 11:59:46 AM »
I thought it might be something like that, but as you can see in the first post that isn't the case for my text.  Maybe if I post a small drawing showing the issue it will help.
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: How to tell mtext character width?
« Reply #3 on: July 15, 2009, 12:11:34 PM »
It's in the STYLE  8-)
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: 12922
  • London, England
Re: How to tell mtext character width?
« Reply #4 on: July 15, 2009, 12:12:01 PM »
Its because the TextStyle has a width factor already.  :-)

EDIT: Beat me to it :P

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to tell mtext character width?
« Reply #5 on: July 15, 2009, 12:18:17 PM »
Dang it.........

Thanks guys.   :oops:
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: How to tell mtext character width?
« Reply #6 on: July 15, 2009, 12:35:22 PM »
Just one of those "Forest for the Trees" moments.
I have them all the time.  :-)
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to tell mtext character width?
« Reply #7 on: July 15, 2009, 12:39:34 PM »
Just one of those "Forest for the Trees" moments.
I have them all the time.  :-)

Yup.  Looking for the complex answer, when the simple one is right there.......

< where is that delete topic button.... can't leave any proof.... >
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Spike Wilbury

  • Guest
Re: How to tell mtext character width?
« Reply #8 on: July 15, 2009, 12:41:34 PM »
Just one of those "Forest for the Trees" moments.
I have them all the time.  :-)

Well... ask me (no, better not).... I'm going to the drain with lisp - dang! by 4 :)   [just read my signature]

DEVITG

  • Bull Frog
  • Posts: 481
Re: How to tell mtext character width?
« Reply #9 on: September 15, 2009, 11:33:46 AM »
Following the topic

I have a lisp where I ask the user to select a Mtext as to be the sample to  do new MTEXT
Often this sample text is only a few character , and new MTEX will be a few more char.
How can I set the proper mtext width, regarding the new String STRLEN? 

The new string at the new text will be as follow.

Code: [Select]
(setq ini-linea (vlax-curve-getstartpoint linea-obj))   
(setq fin-linea (vlax-curve-getendpoint linea-obj))
(setq x-ini ( rtos (car ini-linea) 2 4))
(setq y-ini ( rtos (cadr ini-linea) 2 4))
(setq x-fin ( rtos (car fin-linea) 2 4))
(setq y-fin ( rtos (cadr fin-linea) 2 4))
(setq ini-text$ (strcat "X= "  x-ini "\n""Y= "  y-ini))
(setq fin-text$ (strcat "X= "  x-fin "\n"  "Y= "  y-fin))
(setq text-lenght (strlen ini-text$))

I did it by guess

Code: [Select]
(setq texto-obj-width ( * text-lenght texto-heigth))
 
 
So I need to set the Mtext width


Code: [Select]
(setq text-ini (add-mtext   ini-text$  ini-linea 1))
 (vla-put-stylename text-ini texto-style)
 (vla-put-Height text-ini texto-obj-height)
(vla-put-Width  text-ini  texto-obj-width)

Add-mtetx , is as follow

Code: [Select]
(defun add-mtext  (str pt Width)
  (if (= (type pt) 'LIST)
    (setq pt (vlax-3d-point pt)))
  (vla-addmtext model pt Width str)
  )






Location @ Córdoba Argentina Using ACAD 2019  at Window 10