Renumbering Detail Number based on location

BCampbellNWL
Contributor
Contributor

Renumbering Detail Number based on location

BCampbellNWL
Contributor
Contributor

Hey all! I'm developing a tool that will renumber views on a sheet based on their location in relationship to our title block. I'm super close, but when I go to set the value nothing happens. Anyone know why the SetValueString() method wouldn't work?

 

FilteredElementCollector viewportCollector = new FilteredElementCollector(doc.ActiveView.Document)
                .OfCategory(BuiltInCategory.OST_Viewports)
                .WhereElementIsNotElementType();

int arbitrarySet = 1000;

Transaction t2 = new Transaction(doc);
    t2.Start("Reset Detail Numbers");

    foreach (Element vp in viewportCollector)
     {
              arbitrarySet++;
              vp.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER).SetValueString(arbitrarySet.ToString());
                
      }
      t2.Commit();

 

(This portion is designed to renumber them to something arbitrary to avoid duplicate errors)

 

0 Likes
Reply
Accepted solutions (1)
214 Views
2 Replies
  • API
Replies (2)

RPTHOMAS108
Mentor
Mentor
Accepted solution

Note remarks section for Parameter.SetValueString in RevitAPI.chm:

 

"The method only applies to parameters of value types."

 

String is not a value type so use Parameter.Set.

 

There is also unit parsing overhead associated with SetValueString for value types.

 

BCampbellNWL
Contributor
Contributor

@RPTHOMAS108  Thank you so much! Worked Like a charm! This API can be very confusing sometimes! haha I'll get the hang of it eventually!

0 Likes