Dear Aleksandr,
Have you tried using Dimension.ValueOverride Property
http://revitapisearch.com/html/4560ec6c-5aab-fcae-a64c-6f939ae06d94.htm
Hope it helps.
Cheers,
Thank you Jaime,
I have seen that, but I do not know how to apply... Tried in different ways, sometimes Revit crashes. It would be nice to get a ready example.
Thanks.
I have also observed a Revit crash when accessing a DimensionSegment.ValueOverride property via a System.AccessViolationException when the .ValueOverride property has no value. It will also crash if the .Below, .Above, .Prefix, or .Suffix properties are accessed when they contain no value.
I found a workaround on stackoverflow, How to handle AccessViolationException, which has links to some addition articles on MSDN.
Basically you wrap reads to those properties in a Try/Catch block and decorate the calling method with a [HandleProcessCorruptedStateExceptions] attribute (The stackoverflow link has other solutions but this is the only one that I've tried).
[HandleProcessCorruptedStateExceptions] private void GetOverride(Dimension singleSegmentDimension) { try { ValueOverride = singleSegmentDimension.ValueOverride; } catch (System.AccessViolationException ex) { //Handle the scary "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." message... } }
Thanks Bobby, but... I want write different value to Value Override of Dimension.
I haven't tested yet, but this may have been addressed in 2016 SP2 per the release notes.
Both.
<unrelated side rant>
I REALLY HATE that we have to handle single and multiple segments differently! Sorry, but sometimes you just gotta let that stuff out 🙂