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: 

Renumbering Detail Number based on location

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
BCampbellNWL
209 Views, 2 Replies

Renumbering Detail Number based on location

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)

 

Labels (1)
  • API
2 REPLIES 2
Message 2 of 3
RPTHOMAS108
in reply to: BCampbellNWL

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.

 

Message 3 of 3
BCampbellNWL
in reply to: BCampbellNWL

@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!

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

Post to forums  

Autodesk Design & Make Report