Code Red > .NET
Mtext.GeometryExtents return wrong information
LE:
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#: ---foreach (ObjectId objId in this.ModelSpace) { Entity entity = (Entity)this.Transaction.GetObject(objId, OpenMode.ForRead, false); if (entity.Visible) { RealDWGApplication.WorkingDatabase = this.Database; if (entity is MText) { minX = entity.GeometricExtents.MinPoint.X; minY = entity.GeometricExtents.MinPoint.Y; maxX = entity.GeometricExtents.MaxPoint.X; maxY = entity.GeometricExtents.MaxPoint.Y; } } }
User48:
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:
--- Quote from: LE on July 12, 2012, 11:53:50 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?
--- End quote ---
Just a shot in the dark
Try instead
entity.Bounds.MinPoint etc
~'J'~
LE:
--- Quote from: fixo on July 13, 2012, 01:05:10 am ---entity.Bounds.MinPoint etc
--- End quote ---
Nope, that does not work - Thanks!
LE:
--- Quote from: User48 on July 12, 2012, 08: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.
--- End quote ---
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#: ---TextStyleTable textStyleTable = this.Transaction.GetObject(this.Database.TextStyleTableId, OpenMode.ForRead) as TextStyleTable; if (textStyleTable.Has(mtxt.TextStyleName)) { ObjectId textStyleId = textStyleTable[mtxt.TextStyleName]; Autodesk.AutoCAD.GraphicsInterface.TextStyle iStyle = new Autodesk.AutoCAD.GraphicsInterface.TextStyle(); if (fromAcDbTextStyle ( iStyle.UnmanagedObject, ref textStyleId ) == Autodesk.AutoCAD.Runtime.ErrorStatus.OK ) { Extents2d extents = iStyle.ExtentsBox(mtxt.Text,true,true,null); double width = extents.MaxPoint.X - extents.MinPoint.X; double height = extents.MaxPoint.Y - extents.MinPoint.Y; } } 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*
Navigation
[0] Message Index
[#] Next page
Go to full version