[Solved] Rhinocommon: How to update DimStyle in document. Rhino 6

Hi, I am just looking to format some dimension objects. Sounds like the best thing to do is just to assign an instance of a DimensionStyle; however, I am having troubles updating/pushing any change I make to the dimension style to the document as CommitChanges() does not exist anymore in Rhino 6. Can anyone point me to the right direction please?

This was my quick test:

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        int dimStyleIndex = doc.DimStyles.Add("myDimStyle", false);
        DimensionStyle myDimStyle = doc.DimStyles[dimStyleIndex];
        myDimStyle.TextHeight = 2.5;
        myDimStyle.ArrowLength = 2;
        //myDimStyle.CommitChanges(); 

        LinearDimension lineardim = new LinearDimension(Plane.WorldXY, new Point2d(0, 0), new Point2d(8, 0), new Point2d(0, 3));
        lineardim.DimensionStyleId = myDimStyle.Id;

        Rhino.DocObjects.ObjectAttributes attr = new Rhino.DocObjects.ObjectAttributes();
        Guid id = doc.Objects.AddLinearDimension(lineardim, attr);
        doc.Views.Redraw();

        return Result.Success;
    }

Instead of

myDimStyle.CommitChanges();

you can use

doc.DimStyles.Modify(myDimStyle, dimStyleIndex, false);
1 Like

Sweet! Worked as expected. Thanks for that.

Lowell,

my understanding is that if I want to modify a dimStyle I must use

doc.DimStyles.Modify(...);

for Rhino 6 or

myDimStyle.CommitChanges();

for Rhino 5. What about if my plug-in must run under both versions?

Thanks. L

Rhino 5 also has a DimensionStyle.CommitChanges method.

– Dale