Author Topic: Mtext.GeometryExtents return wrong information  (Read 4953 times)

0 Members and 1 Guest are viewing this topic.

LE3

  • Guest
Mtext.GeometryExtents return wrong information
« on: July 12, 2012, 12:53:50 PM »
The code below works on REALDWG 2009, but at REALDWG 2013 the Mtext.GeometryExtents not...

Any comments or ideas? or should we need to use something else?

Code - C#: [Select]
  1. foreach (ObjectId objId in this.ModelSpace)
  2. {
  3. Entity entity = (Entity)this.Transaction.GetObject(objId, OpenMode.ForRead, false);
  4. if (entity.Visible)
  5. {
  6. RealDWGApplication.WorkingDatabase = this.Database;
  7. if (entity is MText)
  8. {
  9. minX = entity.GeometricExtents.MinPoint.X;
  10. minY = entity.GeometricExtents.MinPoint.Y;
  11. maxX = entity.GeometricExtents.MaxPoint.X;
  12. maxY = entity.GeometricExtents.MaxPoint.Y;
  13. }
  14. }
  15. }
  16.  

twdotson

  • Mosquito
  • Posts: 17
Re: Mtext.GeometryExtents return wrong information
« Reply #1 on: July 12, 2012, 09:37:15 PM »
No experience with RealDWG, but in AutoCAD I have always had good results using .Location along with .ActualHeight and .ActualWidth, taking into account the .Attachment value.

fixo

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #2 on: July 13, 2012, 02:05:10 AM »
The code below works on REALDWG 2009, but at REALDWG 2013 the Mtext.GeometryExtents not...
Any comments or ideas? or should we need to use something else?

Just a shot in the dark
Try instead
entity.Bounds.MinPoint etc

~'J'~

LE3

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #3 on: July 13, 2012, 10:51:54 AM »
entity.Bounds.MinPoint etc
Nope, that does not work - Thanks!

LE3

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #4 on: July 13, 2012, 10:58:50 AM »
No experience with RealDWG, but in AutoCAD I have always had good results using .Location along with .ActualHeight and .ActualWidth, taking into account the .Attachment value.

Yes, I just did a quick test and that looks that can work, but these properties were tried back some years ago and they got some issues...

Also for example this works in realdwg2009 but not on the 2013 version:
Code - C#: [Select]
  1. TextStyleTable textStyleTable = this.Transaction.GetObject(this.Database.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
  2.      
  3.                                      if (textStyleTable.Has(mtxt.TextStyleName))
  4.                                      {
  5.                                          ObjectId textStyleId = textStyleTable[mtxt.TextStyleName];
  6.                                         Autodesk.AutoCAD.GraphicsInterface.TextStyle iStyle
  7.                                             = new Autodesk.AutoCAD.GraphicsInterface.TextStyle();
  8.      
  9.                                         if (fromAcDbTextStyle
  10.                                                 (
  11.                                                     iStyle.UnmanagedObject,
  12.                                                     ref textStyleId
  13.                                                 ) == Autodesk.AutoCAD.Runtime.ErrorStatus.OK
  14.                                             )
  15.                                         {
  16.                                             Extents2d extents = iStyle.ExtentsBox(mtxt.Text,true,true,null);
  17.                                                double width  = extents.MaxPoint.X - extents.MinPoint.X;
  18.                                                double height = extents.MaxPoint.Y - extents.MinPoint.Y;
  19.                                             }
  20.                                      }
  21.  
It return ZERO (the ExtentsBox) ... so guess it is a new bug or ?

Comments are welcome! - Thanks

edit: added here a link to the location of the above code:
http://adndevblog.typepad.com/autocad/2012/05/actual-width-and-height-of-a-text-string.html
*That does not work*
« Last Edit: July 13, 2012, 11:13:18 AM by LE »

twdotson

  • Mosquito
  • Posts: 17
Re: Mtext.GeometryExtents return wrong information
« Reply #5 on: July 13, 2012, 11:15:54 AM »
I use special methods on Mtext, DbText on all versions and even on RasterImages on 2007.  On everything else GeometricExtents seems to work.

LE3

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #6 on: July 13, 2012, 11:21:37 AM »
I use special methods on Mtext, DbText on all versions and even on RasterImages on 2007.  On everything else GeometricExtents seems to work.
Yes... as mentioned it works using RealDWG 2009 - so it must be a *bug* introduced on the 2013 version... we submitted also to adn and lets see what they have to comment on this too.

Thanks.

LE3

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #7 on: July 13, 2012, 11:36:10 AM »
No experience with RealDWG, but in AutoCAD I have always had good results using .Location along with .ActualHeight and .ActualWidth, taking into account the .Attachment value.

Oh... and by the way these properties return ZERO.... on RealDWG 2013.... hmmmm

LE3

  • Guest
Re: Mtext.GeometryExtents return wrong information
« Reply #8 on: July 13, 2012, 03:19:01 PM »
Well.... after all the debugging.... the problem was the font path!.... so user/programmer problem (good it was not me)

Thanks guys!

edit: resolved
« Last Edit: July 14, 2012, 09:33:21 AM by LE »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Mtext.GeometryExtents return wrong information
« Reply #9 on: July 13, 2012, 05:45:26 PM »
Have you tried MText.GetBoundingPoints()?