Hello. I know this is after such a long time. So I created a ViewSection Instance and want to set a string value to a parameter (pre-created by me) of the newly created section. I used IUpdater interface. And the catch told me that the parameter is read-only. Can you please look at this piece of my code and tell me what I did wrong?
public class CreateViewSections : IExternalCommand
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// I do something here
tUp = new TUpdate(commandData.Application.ActiveAddInId, field);
UpdaterRegistry.RegisterUpdater(tUp, doc);
UpdaterRegistry.RemoveAllTriggers(tUp.GetUpdaterId());
UpdaterRegistry.AddTrigger(tUp.GetUpdaterId(), allSections, Element.GetChangeTypeElementAddition());
using (Transaction t = new Transaction(doc, "Create View Sections"))
{
t.Start();
// Create sections
t.Commit();
}
public class TUpdate : IUpdater
{
static UpdaterId _updaterId;
static AddInId Id;
private FieldClass _field;
public TUpdate (AddInId aId)
{
Id = aId;
_updaterId = new UpdaterId (Id, new Guid("75674032-EE16-481B-B9F5-46E878DF3F12"));
}
public void Execute(UpdaterData data)
{
try
{
int i = 0;
foreach (ElementId id in data.GetAddedElementIds())
{
Document doc = data.GetDocument();
Element e = doc.GetElement(id);
e.LookupParameter("View Name").Set(i.ToString());
e.LookupParameter("TMark").Set(i.ToString());
i++;
}
}
catch (Exception e)
{
TaskDialog.Show("TUpdate", e.Message);
}
}
public string GetAdditionalInformation()
{
return "Additional Info";
}
public ChangePriority GetChangePriority()
{
return ChangePriority.Structure;
}
public UpdaterId GetUpdaterId()
{
return _updaterId;
}
public string GetUpdaterName()
{
return "TUpdate";
}
}