
Not applicable
01-29-2021
02:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to change the "Mark" values of family objects in a schedule view, but I am having a bit of trouble. Is there a way to do this by element ID? Currently I am just listing information about each family elements on a specific row, but I would like to change the mark parameters (or other string data).
This is what I have so far:
public class renumberBOM : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// Get document ID
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
//Application app = uiapp.Application;
Document doc = uidoc.Document;
// Get active view type
Autodesk.Revit.DB.View activeView = doc.ActiveView;
////////////////////////////
// Count schedule entries //
////////////////////////////
// check if active view is a schedule
if (activeView is Autodesk.Revit.DB.ViewSchedule)
{
////////////////////////////////////
// Active/open view is a schedule //
////////////////////////////////////
// Create new container for output string
StringBuilder sb = new StringBuilder();
ViewSchedule view = doc.ActiveView as ViewSchedule;
//if (view==null) return;
TableData table = view.GetTableData();
TableSectionData section = table.GetSectionData(SectionType.Body);
// Create list of element rows to loop though
List<ElementId> elems = new FilteredElementCollector(doc,view.Id).ToElementIds().ToList();
// Create list of elements on row
List<Element> ElementsOnRow = new List<Element>();
List<ElementId> Remaining = null;
// Set static row (2) to analyze
int RowToAnalyse = 2;
using(Transaction t = new Transaction(doc, "dummy"))
{
t.Start();
// Remove row (2) to analyze
using (SubTransaction st = new SubTransaction(doc))
{
st.Start();
section.RemoveRow(RowToAnalyse);
st.Commit();
}
// Iterate through set of elements
Remaining = new FilteredElementCollector(doc,view.Id).ToElementIds().ToList();
t.RollBack();
}
// List each component in row (2)
int ctr = 1;
int startValue = 0;
// Get each element in schedule row (2) based on ID
foreach(ElementId id in elems)
{
if(Remaining.Contains(id)) continue;
ElementsOnRow.Add(doc.GetElement(id));
}
// List quantity of elements on row (2)
sb.AppendLine(string.Format("{0} elements on row {1}", ElementsOnRow.Count, RowToAnalyse));
sb.AppendLine("");
foreach(Element e in ElementsOnRow)
{
// List each family-element-ID, family-name and family-type, family-category
sb.AppendLine(string.Format("<{0}> {1} {2} {3}", e.Id, e.Name, e.GetType(), e.Category));
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Set element mark values here????
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
}
TaskDialog.Show("Schedule Data", sb.ToString());
}
else
{
// Active/open view is NOT a schedule
TaskDialog.Show("Error", "Make sure a schedule is opened before running this tool");
}
/////////////////////
// Show dialog box //
/////////////////////
//TaskDialog.Show("AHI Dialog", "BOM/Schedule renumbered");
return Result.Succeeded;
}
}
Solved! Go to Solution.