[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;

        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);

        return Result.Success;

Instead of


you can use

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

Sweet! Worked as expected. Thanks for that.