How would one change the annotation style for all the selected text blocks in a file?
Have found an example of how to do it with dimensions but it does not work with text blocks.
How would one change the annotation style for all the selected text blocks in a file?
Have found an example of how to do it with dimensions but it does not work with text blocks.
Hi Miano,
I did this in a C# comp, but you can easily turn it in to a RhinoCommand. The provided method is a skin and bones and you can easily extend it and add more functionality. Since you didint specify the language, I wrote it in my all time favorite C#
/// <summary>
/// Changes the annotation style of all texts in the current Rhino Doc
/// This method can be easily modified to change evry text object with a a specifc style
///given a List of properties as arguments to the method
/// </summary>
/// <param name="doc"></param>
/// <param name="fontName"></param>
/// <param name="fontWeight"></param>
/// <param name="fontStyle"></param>
/// <param name="textHeight"></param>
/// <returns></returns>
public void ChangeAnnotationStyle(string fontName, int fontWeight, int fontStyle, double textHeight)
{
Rhino.DocObjects.Font.FontWeight _fontWeight = Rhino.DocObjects.Font.FontWeight.Unset;
Rhino.DocObjects.Font.FontStyle _fontStyle = Rhino.DocObjects.Font.FontStyle.Unset;
switch (fontWeight)
{
case 0: _fontWeight = Rhino.DocObjects.Font.FontWeight.Unset; break;
case 1: _fontWeight = Rhino.DocObjects.Font.FontWeight.Thin; break;
case 2: _fontWeight = Rhino.DocObjects.Font.FontWeight.Ultralight; break;
case 3: _fontWeight = Rhino.DocObjects.Font.FontWeight.Light; break;
case 4: _fontWeight = Rhino.DocObjects.Font.FontWeight.Normal; break;
case 5: _fontWeight = Rhino.DocObjects.Font.FontWeight.Medium; break;
case 6: _fontWeight = Rhino.DocObjects.Font.FontWeight.Semibold; break;
case 7: _fontWeight = Rhino.DocObjects.Font.FontWeight.Bold; break;
}
switch (fontStyle)
{
case 0: _fontStyle = Rhino.DocObjects.Font.FontStyle.Unset; break;
case 1: _fontStyle = Rhino.DocObjects.Font.FontStyle.Upright; break;
case 2: _fontStyle = Rhino.DocObjects.Font.FontStyle.Italic; break;
case 3: _fontStyle = Rhino.DocObjects.Font.FontStyle.Oblique; break;
}
foreach (var rhinoObject in doc.Objects.GetObjectList(Rhino.DocObjects.ObjectType.Annotation))
{
Rhino.DocObjects.AnnotationObjectBase annotationObject = rhinoObject as Rhino.DocObjects.AnnotationObjectBase;
if (annotationObject == null) continue;
Rhino.Geometry.AnnotationBase annotation = annotationObject.Geometry as Rhino.Geometry.AnnotationBase;
if (annotation == null) continue;
annotation.Font = new Rhino.DocObjects.Font(fontName, _fontWeight,
_fontStyle, false, false);
annotation.TextHeight = textHeight;
annotationObject.CommitChanges();
}
}
Thanks, I am doing Python on a mac but can convert.