A scale object uses paper units, drawing units, scale factor, scale name, temporary status, and default status to define the scale. In examples, the pScale variable stores a pointer to the scale object.
The property stores the scale factor as a positive non-zero Double value. This factor depends on the value of the paper units and the value of the drawing units. The paper and drawing units define the ratio in which units of model space correlate to the units of paper space. The scale indicates how many paper units fit to one drawing unit. The scale factor is the calculated value defined only by the paper and drawing units. The initial value is 1.0 by default.
To get the scale factor, use the scale() method; it does not have arguments and returns the factor as a Double value. For example:
odPrintConsoleString(L"\nScale = %f", pScale->scale());
The scale factor is a read-only property. To modify the scale factor, use the paper units and drawing units of the scale object.
To get the paper units, use the paperUnits() method; it does not have arguments and returns the paper units as a Double value. For example:
odPrintConsoleString(L"\nPaper Units = %f", pScale->paperUnits());
To set the paper units, use the setPaperUnits() method; it requires one argument — the number of units as a positive non-zero Double value — and does not return a value. For example:
pScale->setPaperUnits(3.0);
To get the drawing units, use the drawingUnits() method; it does not have arguments and returns the drawing units as a Double value. For example:
odPrintConsoleString(L"\nDrawing Units = %g", pScale->drawingUnits());
To set the drawing units, use the setDrawingUnits() method; it requires one argument — the number of units as a positive non-zero Double value — and does not return a value. For example:
pScale->setDrawingUnits(8.0);
The property stores the internal scale name as a String value. The internal scale name is used as a comment for the ratio of paper units to drawing units when the scale object is displayed in a list. The initial value is an empty string by default.
To get the internal scale name, use the scaleName() method; it does not have arguments and returns the name as an OdString value. For example:
odPrintConsoleString(L"\nScale Name = %g", pScale->scaleName());
To set the internal scale name, use the setScaleName() method; it requires one argument — the new name as an OdString value — and does not return a value. For example:
pScale->setScaleName(L"3:8");
To get the external scale name, use the objectId() method that returns the ID of the scale object, the ownerId() method that returns the ID of the owner object, that is, the scale dictionary, and the nameAt() method of the obtained dictionary object that returns the keyword of the object in the dictionary, that is, the external name. For example:
odPrintConsoleString(L"\nScale Key = %s", ((OdDbDictionary*) pScale->ownerId().safeOpenObject().get())->nameAt(pScale->objectId()););
The temporary status determines whether the scale is temporarily stored in the database. The temporary scale typically exists because attached XREF objects in the drawing have dependencies on scales that are not directly referenced by other objects in the drawing. The scale object defines this property as a Boolean value which is True if the scale is temporary or False if the scale is fixed. The initial value is False (fixed) by default.
To check the status, use the isTemporaryScale() method; it does not have arguments and returns the status as a Boolean value. For example:
odPrintConsoleString(L"\nScale is %s", (pScale->isTemporaryScale()) ? L"Temporary" : L"Fixed");
To switch the status, use the setIsTemporaryScale() method; it requires one argument — the status as a Boolean value — and does not return a value. For example:
// Set the temporary status
pScale->setIsTemporaryScale(true);
// Set the fixed status
pScale->setIsTemporaryScale(false);
Note: Applications should not persist references to temporary scales, because other operations (for example, detaching an XREF) may remove temporary scales from the database. Temporary scales are not filed out to a drawing when it is saved.
The default status determines whether the scale is selected as one-to-one (1:1) by default. The scale object defines this property as a Boolean value which is True if the scale is selected (1:1) by default or False if the scale is not the default. The initial value is False by default.
To check the status, use the isUnitScale() method; it does not have arguments and returns the status as a Boolean value. For example:
odPrintConsoleString(L"\nScale is %s", (pScale->isUnitScale()) ? L"Selected(1:1)" : L"Ordinary");
To switch the status, use the setIsUnitScale() method; it requires one argument — the status as a Boolean value — and does not return a value. For example:
// Set the scale as selected (1:1)
pScale->setIsUnitScale(true);
// Set the scale as ordinary
pScale->setIsUnitScale(false);
Note: The scale dictionary does not control the number of scales selected as (1:1), but applying scales requires only one scale to be selected (1:1). The user application must check the uniqueness of the selected scale.
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|