I need to add text to a drawing that may have a modelspacescale different from 1, but the text needs to drawn at the specified height, ie modelspacescale = 1.
I can’t alter the modelspacescale document wide as other parties may be adding text as well.
I can’t see a setting on the text entity for this.
I have tried temporarily changing the modelspacescale to 1 whilst I add the text, like below, but it doesn’t work.
Just to clarify, we are not using Python scripting, and we are aware of the introduction of Model space scaling in Rhino 6 and Rhino 7, and we are not adding dimensions, just plain text.
What we need to know is how to add a text entity, using vb net and Rhino commons, that has the model space scaling set to 1 for that entity, without altering the document wide model space scaling.
Like @mary said, the global model space scale, found in Rhino 5, was abandoned. In Rhino 6 and newer, each annotation style has it’s own model space scale. Note, all annotations (e.g. dimensions, leaders, text, etc.) use annotation styles.
If you want to create text and has a custom model space scale, then you can do so like this:
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// Get the current annotation) style
var dimStyle = doc.DimStyles.Current;
if (null == dimStyle)
return Result.Failure;
// Create a text entity that uses the annotation style
var textEntity = TextEntity.Create("Hello Rhino!", Plane.WorldXY, dimStyle, false, 0, 0);
if (null == textEntity)
return Result.Failure;
// Override the text height
textEntity.TextHeight = 1.0;
// Override the model space scale
textEntity.DimensionScale = 10.0;
// Add to the document
doc.Objects.AddText(textEntity);
doc.Views.Redraw();
return Result.Success;
}
Thanks, that worked. It was the use of “dimensionscale” to change the text entity model space scale that I had missed.
For reference, here is the code that we ended up using:
Dim t As New TextEntity
t.PlainText = txt
t.Font = New Font(fontname)
t.Plane = myplane
t.TextHeight = ht
t.DimensionScale = 1
doc.Objects.AddText(t, atts)
' where atts is the document default attributes