Annotation style and a couple other items (rhinocommon)

Three problems I’m having today I’m hoping to get some help with:

  1. I’m trying to change the annotation text style using the sample located here: http://wiki.mcneel.com/developer/rhinocommonsamples/dimstyle
    But it seems I need some import statements (I often wonder why these aren’t included…). In particular, AnnotationObjectBase gives me an error. I would try to figure it out on my own with the rhinocommon documentation, but it seems to be down (403 - Forbidden: Access is denied). The offline documentation seems to be having trouble too.

  2. I’ve changed the linetype for a layer, but it does not change to that type until I click on the linetype in rhino. Here is the code I’m using for that:
    Dim LayerLinesIndex = doc.Layers.Add(“Lines”, Drawing.Color.White)
    Dim LayerLines = doc.Layers(LayerLinesIndex)
    LayerLines.LinetypeIndex = 5
    LayerLines.CommitChanges()

  3. I would like to set the viewport display modes to shaded. I think the following sample might be what I’m looking for:
    http://wiki.mcneel.com/developer/rhinocommonsamples/advanceddisplay
    But similar to the annotation style sample, I get an error, this time for DisplayModeDescription I think because there are some import statements missing that I need… Am I even on the right track, perhaps there is a quick simple way to change to shaded mode?

Thanks,
Sam

protected override Rhino.Commands.Result RunCommand(Rhino.RhinoDoc doc, Rhino.Commands.RunMode mode)
{
  foreach (var rhino_object in doc.Objects.GetObjectList(Rhino.DocObjects.ObjectType.Annotation))
  {
    var annotation_object = rhino_object as Rhino.DocObjects.AnnotationObjectBase;
    if (annotation_object == null) continue;

    var annotation = annotation_object.Geometry as Rhino.Geometry.AnnotationBase;
    if (annotation == null) continue;

    if (annotation.Index == doc.DimStyles.CurrentDimensionStyleIndex) continue;

    annotation.Index = doc.DimStyles.CurrentDimensionStyleIndex;
    annotation_object.CommitChanges();
  }

  doc.Views.Redraw();

  return Rhino.Commands.Result.Success;
}

The standard documents included with Rhino do not contain any other linetype than continuous. So before assigning a linetype index to a layer, you might want to make sure the linetype exists in the document (RhinoDoc.Linetypes). Note, clicking a linetype control in Rhino adds the linetype(s) for you, which is why it works after you click…

Actually, this sample shows you how to modify an existing display mode, which isn’t what you say you are looking for. How about this sample?

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsShadedView.cs

Got a question about the last example of the ShadedView.

Why do you use @"Shaded"; and not just "Shaded"; ?

The @ escapes escaping.
That stuff is useful to define string constants in a verbatim way instead of escaping every hyphen or backslash. Just makes the constants more readable.

In this case the result of @“Shaded” and “Shaded” is identical.

Got #1 and #3, thanks,

In regards to your answer for question 2, I think you’re talking about something a bit over my head; I’m not sure how the standard document doesn’t have additional linetypes, but the document that opens when rhino opens does have multiple line types.

Basically, I want to be able to create curves with line type anything other than continuous. How can I do this?

Thanks,
Sam

This works:

Dim layer As New Rhino.DocObjects.Layer
layer.Color = System.Drawing.Color.Blue
layer.LinetypeIndex = doc.Linetypes.Count - 1
doc.Layers.Add(layer)

If you modifying an existing layer that contains geometry, you will want to redraw all viewports to update the display.

doc.Views.Redraw()

Works, thanks Dale!

Sam