Message 1 of 4
Modify Shared Parameters for high number of family instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have the code below working fine when my collection contain less than 30 objet; above 30 the transaction commit doesn't affect document and there is no error or exception raised. Did some one have an idea to solve this?
void IExternalEventHandler.Execute(UIApplication app)
{
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
View view = doc.ActiveView;
using (Transaction tr = new Transaction(doc))
{
Parameter param1 = null;
Parameter param2;
Parameter param3 ;
Parameter param4 = null;
Parameter param5 = null;
Parameter param6 = null;
Parameter param7 = null;
tr.Start("synchro");
for(int i = 0; i < Main.idForSynchros.Count; i++) // Main.idForSynchro is the collection of data
{
IdForSynchro idForSynchro = Main.idForSynchros[i];
Element element = doc.GetElement(new ElementId(Convert.ToInt32(idForSynchro.RevitId)));
param1 = element.LookupParameter("PLUGIN_PARAM1");
param2 = element.LookupParameter("PLUGIN_PARAM2");
param3 = element.LookupParameter("PLUGIN_PARAM3");
param4 = element.LookupParameter("PLUGIN_PARAM4");
param5 = element.LookupParameter("PLUGIN_PARAM5");
param6 = element.LookupParameter("PLUGIN_PARAM6");
param7 = element.LookupParameter("PLUGIN_PARAM7");
if (param1.AsInteger() < 1)
{
param1.Set(idForSynchro.param1);
}
string param6Value = DateTime.Parse(idForSynchro.data.param6, CultureInfo.InvariantCulture).ToLongDateString();
string param7Value = DateTime.Parse(idForSynchro.data.param7, CultureInfo.InvariantCulture).ToLongDateString();
Utils.SetParameterValueString(param2, idForSynchro.data.param2);
Utils.SetParameterValueString(param3, idForSynchro.data.param2);
Utils.SetParameterValueString(param4, idForSynchro.data.param4);
Utils.SetParameterValueString(param5, idForSynchro.data.param5);
Utils.SetParameterValueString(param6, param6Value);
Utils.SetParameterValueString(param7, param7Value);
}
tr.Commit();
}
}
// Method of Utils class that set Parameter value
public static void SetParameterValueString(Parameter parameter, string value)
{
if (parameter != null)
{
parameter.Set(value);
}
}