This topic describes methods that are used for formatting dimension text.
The Dimtxt
value controls the dimension text size. This value influences both
the height and width of the dimension text and is used as a scale factor for
character spacing. The initial value is 0.18.
Note: If the current text style has a fixed text height, this value is ignored. Tolerances have a scale factor that specifies the tolerance text size relative to the dimension text size.
To get the value of Dimtxt
, use the dimtxt()
method, which returns the dimension
text size as a double value.
For example:
odPrintConsoleString(L"\ndimtxt is %f", pDimension->dimtxt());
To set a new dimension text size, use the setDimtxt()
method, which requires
one double parameter to specify the new dimension text size.
For example:
pDimension->setDimtxt(0.7);
You can split dimension text into several lines by adding control symbols '\X' or '\P' to the text:
Note: Unlike '\P', '\X' is not a regular formatting code for multiline text and can be used for dimension text only.
For example, you can use the '\X' symbol to place measured values in primary and alternative units above and below the dimension line respectively:
// Enable measurement in alternate units
pDimension->setDimalt(true);
// Set the '\X' code as a suffix for the primary measurement to place the alternate measurement line under the dimension line
pDimension->setDimpost(L"<>\X");
The text line spacing factor is the relative distance between adjoining base lines of text strings. The line spacing factor can have a value in the range of 0.25 to 4.0. The initial value is 1.0.
To get the text line spacing factor, use the textLineSpacingFactor()
method,
which returns the text line spacing factor as a double value.
For example:
odPrintConsoleString(L"\nText line spacing factor is %f", pDimension->textLineSpacingFactor());
To set a new text line spacing factor, use the setTextLineSpacingFactor()
method,
which requires one double parameter to specify the new factor value.
For example:
pDimension->setTextLineSpacingFactor(1.5);
The text line spacing style indicates whether the distance between multiline text lines is adjusted
automatically or set equally. The line spacing style is defined by the OdDb::LineSpacingStyle
enumeration,
which can be set to AtLeast
or Exactly
.
The AtLeast value automatically adjusts spacing between different lines of text based on the height of the largest character in a line of text.
The Exactly value forces the line spacing to be the same size for all lines in the text regardless of format changes.
To get the text line spacing style, use the textLineSpacingStyle()
method,
which returns the text line spacing style as an integer value.
For example:
int sp_style = pDimension->textLineSpacingStyle();
OdString str;
switch(sp_style)
{
case 1:
str = "AtLeast";
break;
case 2:
str = "Exactly";
break;
}
odPrintConsoleString(L"\nText line spacing style is set to %s", str.c_str());
To set a new text line spacing style, use the setTextLineSpacingStyle()
method,
which requires one value from the OdDb::LineSpacingStyle
enumeration.
For example:
pDimension->setTextLineSpacingStyle(OdDb::LineSpacingStyle::kExactly));
The text attachment is the dimension text justification mode within the text box. The values of it
are defined by the OdDbMText::AttachmentPoint
enumeration.
enum AttachmentPoint {
kTopLeft = 1,
kTopCenter = 2,
kTopRight = 3,
kMiddleLeft = 4,
kMiddleCenter = 5,
kMiddleRight = 6,
kBottomLeft = 7,
kBottomCenter = 8,
kBottomRight = 9,
};
To get the text attachment value, use the textAttachment()
method, which returns
the text attachment value as one value from the OdDbMText::AttachmentPoint
enumeration.
For example:
odPrintConsoleString(L"\nText attachment value = %d", pDimension->textAttachment());
To set a new text attachment value, use the setTextAttachment()
method, which
requires one value from the OdDbMText::AttachmentPoint
enumeration.
For example:
pDimension->setTextAttachment(OdDbMText::AttachmentPoint::kTopAlign);
To get the dimension text color, use the dimclrt()
method, which returns the
dimension text color as an object of the OdCmColor
class.
odPrintConsoleString(L"\nDimension text color is (%d, %d, %d)", pDimension->dimclrt().red(), pDimension->dimclrt().green(), pDimension->dimclrt().blue());
To set a new dimension text color, use the setDimclrt()
method, which requires
an object of the OdCmColor
class as a new color.
For example:
OdCmColor txtCol = OdCmColor();
txtCol.setRGB(255, 0, 0);
pDimension->setDimclrt(txtCol);
Note: This value does not influence the border of the dimension text box.
Dimension text boxes can be filled with a specified color. To do so, the method
setDimtfill(2)
should be called first.
To get the dimension text fill color, use the dimtfillclr()
method, which returns
the fill color as an object of the OdCmColor
class.
For example:
odPrintConsoleString(L"\nDimension text filling color is (%d, %d, %d)", pDimension->dimtfillclr().red(), pDimension->dimtfillclr().green(), pDimension->dimtfillclr().blue());
To set a new dimension text fill color, use the setDimtfillclr()
method, which
requires an object of the OdCmColor
class as the new color.
For example:
OdCmColor txtFillCol = OdCmColor();
txtFillCol.setRGB(0, 0, 255);
pDimension->setDimclrt(txtFillCol);
The Dimtfill
value indicates how the background of a dimension text box is
filled. It can be one of the following values:
To get the Dimtfill
value, use the dimtfill()
method, which returns the Dimtfill
value as an OdInt16
value.
For example:
odPrintConsoleString(L"\nDimtfill value is %d", pDimension->dimtfill());
To set a new Dimtfill value to a dimension entity, use the setDimtfill()
method,
which requires one OdInt16 parameter as a new Dimtfill
value.
For example:
pDimension->setDimtfill(2);
Working with Common Dimension Entity
Working with General Dimension Methods
Working with Dimension Fit and Movement
Working with Dimension Tolerances
Working with Primary Unit Measurements
Working with Alternate Unit Measurements
Marking the Center of Dimensions
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|