本帖最后由 badboy518 于 2011-11-26 13:13 编辑
代码如下:
-
- Transaction tr = Tools.Database.TransactionManager.StartTransaction();
- Polyline curLine = tr.GetObject(polyid, OpenMode.ForRead) as Polyline;
-
- DBText mText = new DBText();
- mText.SetDatabaseDefaults();
- mText.TextString = "面积:"+Math.Round(curLine.Area, 3).ToString();
- mText.Position = curLine.GeometricExtents.MaxPoint;
- ObjectId mid = Tools.AddToCurrentSpace(mText);
- mText = tr.GetObject(mid, OpenMode.ForWrite) as DBText;
- mText.VerticalMode = TextVerticalMode.TextVerticalMid; //问题就出在这两句
- mText.HorizontalMode = TextHorizontalMode.TextCenter;
- mText.Height = 5.0;
-
- mText.Position = curLine.GeometricExtents.MaxPoint;
-
-
- tr.Commit();
当指定text的对齐方式,加入数据库后,文字的position总是在原点,试了好多办法都行不通。
请高手指点一下
自己找到解决办法了。。晕,刚发的贴。
- mText.VerticalMode = TextVerticalMode.TextVerticalMid;
- mText.HorizontalMode = TextHorizontalMode.TextCenter;
- mText.AlignmentPoint = curLine.GeometricExtents.MaxPoint; //这句是关键
|