Hi. I’m trying to read text info from OpenNurbs. When I try to get the text height, I think I should do like this:
double textHeight = dimStyle.TextHeight() ;
But I got a wrong height value. After checking the model, I found that it’s the model space scale that affects the text scale.
So I do like this:
double textHeight = dimStyle.TextHeight() * dimStyle.DimScale();
double textHeight = dimStyle.TextHeight() * pText->DimScale(&dimStyle);
But I still got the wrong value because dimStyle.DimScale() returns 1.0, not 0.001. After checking the model again, I find that both the text and the annotation style have a model space scale and will affect the text scale respectively:
ONX_ModelComponentIterator it(model, ON_ModelComponent::Type::ModelGeometry);
const ON_ModelComponent* model_component = nullptr;
for (model_component = it.FirstComponent(); nullptr != model_component; model_component = it.NextComponent())
const ON_ModelGeometryComponent* model_geometry = ON_ModelGeometryComponent::Cast(model_component);
if (nullptr != model_geometry)
const ON_Annotation* annotation = ON_Annotation::Cast(model_geometry->Geometry(nullptr));
if (nullptr == annotation)
// Get the id of the main (parent) dimstyle used by this object.
// The style with this id should not be used directly if there is
// an override dimstyle present.
ON_UUID parent_dimstyle_id = annotation->DimensionStyleId();
// Get a dimension style from its model id.
const ON_ModelComponentReference& parent_dimstyle_ref = model.DimensionStyleFromId(parent_dimstyle_id);
const ON_DimStyle* parent_dimstyle = ON_DimStyle::Cast(parent_dimstyle_ref.ModelComponent());
if (nullptr == parent_dimstyle)
// Get the proper dimension style, including overrides, to use for this
// annotation object.
const ON_DimStyle& dimstyle = annotation->DimensionStyle(*parent_dimstyle);
// Model space scale
printf("Model space scale: %g\n", dimstyle.DimScale());
Hi, Dale. That’s what in my code, which seems similar. But the dimScale is still 1.0.
I also noticed that aText->DimScaleSource() == 0. In this case, is there anything different I should do to get the correct dimscale?
Yes. It works with your test model.
I may find the reason…The text belongs to a block. If this block is exploded, the scale will be correct.
Thank you very much to do further investigation for me. But the model with blocks is too big to upload. How do I upload the model？