Hi All,
I am trying to create a grasshopper node in C# that will create a dimension style in rhino. I found a good portion of code that started me off from this forum post:
I have been able to change the dimension style so that it shows up in fractional dimensions, but I cannot seem to find out how to set the linear resolution of the fractional dim style. Currently the dimension style automatically outputs to the nearest 1/4" but I am looking to create a dimension style that can output to the nearest 1/16". I combed the rhino common api documentation and cannot seem to find which property in the DimensionStyle class controls this.
The current snippet of code that I have is this
private void RunScript(string Name, double Height, ref object A)
{
var style_name = Name;
var text_height = Height;
//Find if the dimension style exists
Rhino.DocObjects.DimensionStyle ds = Rhino.RhinoDoc.ActiveDoc.DimStyles.FindName(style_name);
if (ds == null)
{
Rhino.DocObjects.DimensionStyle dimStyle = new Rhino.DocObjects.DimensionStyle(){
Name = style_name,
Id = Guid.NewGuid(),
DimensionScale = 1,
DimTextLocation = Rhino.DocObjects.DimensionStyle.TextLocation.InDimLine,
DimensionLengthDisplay = Rhino.DocObjects.DimensionStyle.LengthDisplay.InchesFractional,
LengthResolution = 2,
ArrowLength = 1,
ArrowType1 = Rhino.DocObjects.DimensionStyle.ArrowType.None,
ArrowType2 = Rhino.DocObjects.DimensionStyle.ArrowType.None,
TextGap = 1,
TextHeight = text_height,
FixedExtensionOn = false,
ExtensionLineExtension = 0.5,
ExtensionLineOffset = 2,
ToleranceResolution = 16,
Suffix = "\""
};
// Add the newly created text style to the document
Rhino.RhinoDoc.ActiveDoc.DimStyles.Add(dimStyle, false);
//find it again
ds = Rhino.RhinoDoc.ActiveDoc.DimStyles.FindName(style_name);
}
// Set the newly created text style as the current style
Rhino.RhinoDoc.ActiveDoc.DimStyles.SetCurrent(ds.Index, false);
Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
A = ds;
}
Here is where the linear resolution for fractional units is located in the properties for a dimension in rhino:
Any help would be greatly appreciated!
DimStyle.gh (4.9 KB)