文字生成フラグを使用すると、その文字の表示を左右逆にするか、上下逆にするかを指定できます。文字スタイルを使用して文字の表示を左右逆にするか、上下逆にするかを定義するには FlagBits プロパティを使用します。文字オブジェクトを個々にコントロールするには文字オブジェクトの IsMirroredInX および IsMirroredInY プロパティを使用します。
文字を左右逆に表示する場合は FlagBits を 2 に設定し、上下逆に表示する場合は 4 に設定します。文字を左右逆にし、上下も逆にして表示するには、値 6 を使用します。文字オブジェクトを修正する場合、文字を左右逆にするには IsMirroredInX を TRUE に設定し、上下逆に表示するには IsMirroredInY を TRUE に設定します。
次の例は、1 行文字オブジェクトを作成し、IsMirroredInX プロパティを使用して左右逆に表示されるように設定します。
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
[CommandMethod("BackwardsText")]
public static void BackwardsText()
{
// Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// Create a single-line text object
using (DBText acText = new DBText())
{
acText.Position = new Point3d(3, 3, 0);
acText.Height = 0.5;
acText.TextString = "Hello, World.";
// Display the text backwards
acText.IsMirroredInX = true;
acBlkTblRec.AppendEntity(acText);
acTrans.AddNewlyCreatedDBObject(acText, true);
}
// Save the changes and dispose of the transaction
acTrans.Commit();
}
}
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
<CommandMethod("BackwardsText")> _
Public Sub BackwardsText()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
OpenMode.ForRead)
'' Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
'' Create a single-line text object
Using acText As DBText = New DBText()
acText.Position = New Point3d(3, 3, 0)
acText.Height = 0.5
acText.TextString = "Hello, World."
'' Display the text backwards
acText.IsMirroredInX = True
acBlkTblRec.AppendEntity(acText)
acTrans.AddNewlyCreatedDBObject(acText, True)
End Using
'' Save the changes and dispose of the transaction
acTrans.Commit()
End Using
End Sub
Sub BackwardsText()
Dim textObj As AcadText
Dim textString As String
Dim insertionPoint(0 To 2) As Double
Dim height As Double
' Create the text object
textString = "Hello, World."
insertionPoint(0) = 3
insertionPoint(1) = 3
insertionPoint(2) = 0
height = 0.5
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, height)
' Change the value of the TextGenerationFlag
textObj.TextGenerationFlag = acTextFlagBackward
textObj.Update
End Sub