While editing the sketch, I create a new dimension, and later I want to delete it. However, the dimension is never selected and thus never deleted.
private readonly IModelDoc2 _document; private readonly IModelDocExtension _extension; private SketchSegment _lineSplineTangent; private ISketchPoint _pointRight; private IDisplayDimension _dimensionHeight; private void CreateDimension() { _lineSplineTangent.Select(false); _pointRight.Select(true); _dimensionHeight = (IDisplayDimension)_document.AddVerticalDimension2(0, 0, 0); } private void DeleteDimension() { _document.ClearSelection2(true); _document.Extension.SelectByID2(_dimensionHeight.GetNameForSelection(), "DIMENSION", 0, 0, 0, false, 1, null, 0); _extension.DeleteSelection2(); }
How to select a dimension stored in IDisplayDimension object to be able to delete it?
Solved it by using dimension's annotation object to select the dimension itself. IAnnotation is a parent class of many, if not all, types of objects that are used for annotation, including IDisplayDimension.