add additional way to get to Dimension Text dialog (to edit Dimension’s text)

In the Revit Ideas forum it was asked if it can be possible to access this dialog to change dimension text without having to select the dimension’s text itself. Either the text has been overridden with an invisible, empty character, a view break was used, or for some other reason it isn’t simple to select the dimension’s text. Or you want to avoid the problem of moving the dimension text by mistake when you try to click it.

Fortunately, the API gives you access to most everything in this dialog (maybe not “show label in view” and “segment dimension leader visibility”). The code is below to handle a dimension with a single segment (code for the Dialog form is not included) and it could also be enhanced to work with a multi-segment dimension if the form listed the text of each dimension segment so you could specify which segment to modify.

Is there interest in a Udemy lecture showing how to code the form? Or posting it as an app in the Autodesk store?

public void dimText()
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    Dimension dim = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select dimension")) as Dimension;
    if (dim.NumberOfSegments > 1)
        TaskDialog.Show("Error", "Can only run when the dimension has a single segment");
    string above = "";
    string below = "";
    string prefix = "";
    string suffix = "";
    string replaceWithText = "";
    using (FormDimText form = new FormDimText(dim))
        if (form.DialogResult == System.Windows.Forms.DialogResult.Cancel)
        above = form.getAbove();
        below = form.getBelow();
        prefix = form.getPrefix();
        suffix = form.getSuffix();
        replaceWithText = form.getReplace();
    using (Transaction t = new Transaction(doc, "Dim Text"))

        dim.Above = above;
        dim.Below = below;
        if (replaceWithText == null)
            dim.Prefix = prefix;
            dim.Suffix = suffix;    
            dim.ValueOverride = replaceWithText;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s