给个代码(2012中测试通过)- <CommandMethod("placetext")> _
- Sub placetext()
- 'a(0,0) b(200,0) c(200,50) d(0,50)
- Using Trans As Transaction = DB.TransactionManager.StartTransaction
- Dim txt As New DBText
- txt.TextString = "大家好才是真的好"
- Dim BT As BlockTable = Trans.GetObject(DB.BlockTableId, OpenMode.ForRead)
- Dim BTR As BlockTableRecord = Trans.GetObject(BT(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
- BTR.AppendEntity(txt)
- Trans.AddNewlyCreatedDBObject(txt, True)
- '一定要先改高度
- txt.Height = (50 - 0) * txt.Height / (txt.GeometricExtents.MaxPoint.Y - txt.GeometricExtents.MinPoint.Y)
- txt.WidthFactor = (200 - 0) / (txt.GeometricExtents.MaxPoint.X - txt.GeometricExtents.MinPoint.X)
- txt.UpgradeOpen()
- txt.TransformBy(Matrix3d.Displacement(New Point3d(0, 0, 0) - txt.GeometricExtents.MinPoint))
- Trans.Commit()
- End Using
- End Sub
|