I have a particularly annoying client that sends us rhino 5 files using a custom dimension style which is enormous (in font terms) and rounds to closest 1mm. none of the rhino commands work to change the style or load another as the default, mm etc are all missing from the document, this requires us to load styles from another rhino file into the currently open one and redimension everything… major PITA…
Other than picking up a phone and whinging at the client… Whats would be the programtic way to find all dimensions in a document, and change them to read XX.XXmm with actual 0.001 accuracy vs the current 1mm accuracy.
found this, but it relies on the other dim styles already being available in the document… I need to to actually change the existing ones parameters.
(I’ll also send command to them , aptly named “FixYourShittyDimStyles.rhp”)
ok. no. im lost, looks like it should work to me, but must be missing something, I purposefully put out bad dim styles like architectural, and my understanding is this should change them to accuracy 2 decimals and append mm after?
the two debug lines don’t trigger so its finding them, just not changing them?
also the new dim style “FixedDim” is not added to the document.
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var FixedDim = new DimensionStyle();
FixedDim.Name = "FixedDim";
FixedDim.Suffix = "mm.";
FixedDim.LengthResolution = 2;
FixedDim.AngleResolution = 2;
FixedDim.CommitChanges();
foreach (var rhino_object in doc.Objects.GetObjectList(ObjectType.Annotation))
{
var BadDimStyleObjects = rhino_object as AnnotationObjectBase;
if (BadDimStyleObjects == null)
{
RhinoApp.WriteLine("Nothing found 1");//debug
continue;
}
var annotation = BadDimStyleObjects.Geometry as AnnotationBase;
if (annotation == null)
{
RhinoApp.WriteLine("Nothing found 2");//debug
continue;
}
annotation.Index = FixedDim.Index;
BadDimStyleObjects.CommitChanges();
doc.Views.Redraw();
}
return Result.Success;
}
}
Looks like all you need to do is to explicitly call add/replace on the doc objects (doc.objects.add / doc.objects.replace). Remember that you always have to use those to create or modify doc objects.