Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dimension text over-rides

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
2014 Views, 11 Replies

Dimension text over-rides

I would like to change all dimension text include over-rides (above,below, suffix, and prefix) to upper case.

11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

The dimensions have a builtin parameter "BuiltInParameter.DIM_PREFIX" which can be changed. I'm sure the above, below ect. are builtin aswell.

Message 3 of 12
Anonymous
in reply to: Anonymous

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

Message 4 of 12
Anonymous
in reply to: Anonymous

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";
}

 

Message 5 of 12
Anonymous
in reply to: Anonymous

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();
}

Message 6 of 12
Anonymous
in reply to: Anonymous

strange, I use exactly this code in Revit 2016/2017 without problems.

 

Message 7 of 12
Anonymous
in reply to: Anonymous

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();

Message 8 of 12
Anonymous
in reply to: Anonymous

This is what I did :

 

new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_Dimensions)
.WhereElementIsNotElementType()
.ToElements();

Message 9 of 12
Anonymous
in reply to: Anonymous

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;
}
}
}
}

 

 

Message 10 of 12
JimJia
in reply to: Anonymous

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.

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 11 of 12
Anonymous
in reply to: JimJia

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.

Message 12 of 12
dwane
in reply to: Anonymous

Looks like you can select a dim segment within a multi-segment dim

 

https://forums.autodesk.com/t5/revit-api-forum/dimension-segment-select-a-specific-segment-with-a-mo...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community