I would like to change all dimension text include over-rides (above,below, suffix, and prefix) to upper case.
Solved! Go to Solution.
Solved by dwane. Go to Solution.
The dimensions have a builtin parameter "BuiltInParameter.DIM_PREFIX" which can be changed. I'm sure the above, below ect. are builtin aswell.
Thanks for your reply, however, I don't have DIM_SUFFIX or any other the other ones inside the BuiltInParameter.
I'm using Revit 2017. I must be doing something wrong.
Thanks,
Scott
Try this:
private void SetDimValues(Dimension dim)
{
foreach (DimensionSegment dimseg in dim.Segments)
{
dimseg.Prefix = "Prefix Text";
dimseg.Suffix = "Suffix Text";
dimseg.Above = "Above Text";
dimseg.Below = "Below Text";
}
if (dim.Segments.Size != 0) return;
dim.Prefix = "Prefix Text";
dim.Suffix = "Suffix Text";
dim.Above = "Above Text";
dim.Below = "Below Text";
}
Sorry,
I get this... "cannot access this property if this dimension has more than one segment"
foreach (Dimension dim in RDims)
{
Transaction m_transaction = new Transaction(this.uiDoc.Document, "Update Dimensions");
m_transaction.Start();
SetDimValues(dim);
m_transaction.Commit();
}
Is my collector wrong? I'm using FNames instead I posted before.
FamilyFilter = new ElementClassFilter(typeof(Dimension));
FamilyCollector = new FilteredElementCollector(this.uiDoc.Document);
FNames = FamilyCollector.WherePasses(FamilyFilter).ToElements();
This is what I did :
new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_Dimensions)
.WhereElementIsNotElementType()
.ToElements();
This is what I have. I'm missing a reference?
foreach (Dimension dim in FNames)//in new FilteredElementCollector(document).OfClass(typeof(Dimension))
{
if (dim.Segments.Size == 0)
{
string spre = dim.Prefix;
string ssuf = dim.Suffix;
string sabove = dim.Above;
string sbelow = dim.Below;
if (string.IsNullOrEmpty(txtPrefix.Text) && spre != null) txtPrefix.Text = spre;
if (string.IsNullOrEmpty(txtSuffix.Text) && ssuf != null) txtSuffix.Text = ssuf;
if (string.IsNullOrEmpty(txtAbove.Text) && sabove != null) txtAbove.Text = sabove;
if (string.IsNullOrEmpty(txtBelow.Text) && sbelow != null) txtBelow.Text = sbelow;
}
else
{
foreach (DimensionSegment dimseg in dim.Segments)
{
string spre = dimseg.Prefix;
string ssuf = dimseg.Suffix;
string sabove = dimseg.Above;
string sbelow = dimseg.Below;
if (string.IsNullOrEmpty(txtPrefix.Text) && spre != null)//
{
SetDimValues(dim, "Prefix");
}
if (string.IsNullOrEmpty(txtSuffix.Text) && ssuf != null)//
{
SetDimValues(dim, "Suffix");
}
if (string.IsNullOrEmpty(txtAbove.Text) && sabove != null)//
{
SetDimValues(dim, "Above");
}
if (string.IsNullOrEmpty(txtBelow.Text) && sbelow != null)//
{
SetDimValues(dim, "Below");
}
}
}
}
m_transaction.Commit();
private void SetDimValues(Dimension dim, string dimtext)
{
foreach (DimensionSegment dimseg in dim.Segments)
{
switch (dimtext)
{
case "Prefix":
dimseg.Prefix.ToUpper();
break;
case "Suffix":
dimseg.Suffix.ToUpper();
break;
case "Above":
dimseg.Above.ToUpper();
break;
case "Below":
dimseg.Below.ToUpper();
break;
}
if (dim.Segments.Size != 0)
{
switch (dimtext)
{
case "Prefix":
dim.Prefix.ToUpper();
break;
case "Suffix":
dim.Suffix.ToUpper();
break;
case "Above":
dim.Above.ToUpper();
break;
case "Below":
dim.Below.ToUpper();
break;
}
}
}
}
It seems like there are some muti-segment dimension in you document. Currently, Revit API cannot support to access the property like above, suffix and so on for muti-segment dimension.
You should check if the dim.Segments.Size == 1, then
switch (dimtext)
{
case "Prefix":
dim.Prefix.ToUpper();
break;
case "Suffix":
dim.Suffix.ToUpper();
break;
case "Above":
dim.Above.ToUpper();
break;
case "Below":
dim.Below.ToUpper();
break;
}
Hope this will help you, and we appreciate your cooperation and patience.
Thanks for your help,
I check to see if any one of the four segments are populated or not. If so, set a text box with the value.
Then using your code set each segment to the text box value.
Works great.
Thanks again.
Looks like you can select a dim segment within a multi-segment dim
Can't find what you're looking for? Ask the community or share your knowledge.