- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to update a parameter in some pipes, but its not working, what I am doing wrong ? Please see my code below.
I've saw this post:
http://forums.autodesk.com/t5/revit-api/parameters-not-updating/m-p/4311799#M4140
But the solution provided by Augusto did not work for me, using the method "Set" instead of "SetValueString".
The parameter type is string.
public void app_Doc_Change(object sender, DocumentChangedEventArgs args)
{
Document doc = args.GetDocument();
ElementFilter filtro = new ElementClassFilter(typeof(Pipe));
ICollection<ElementId> col = args.GetModifiedElementIds(filtro);
if (col.Count == 0)
return;
string cod_str = "INTT:COD_MAT_COMPLETO",
cod_pre_str = "INTT:COD_PRE_MAT";
bool flag = false;
using (Transaction t = new Transaction(doc, "Atualizar diametro tubos"))
{
foreach (ElementId id in col)
{
Element el = doc.GetElement(id);
Parameter prm1 = el.LookupParameter("Size");
if (prm1 != null)
{
Parameter prm2 = el.LookupParameter(cod_str);
if (prm2 != null)
{
ElementType type = doc.GetElement(el.GetTypeId()) as ElementType;
Parameter prm3 = type.LookupParameter(cod_pre_str);
if (prm3 != null)
{
string valor = prm3.AsString() + "-" + prm1.AsString();
if (prm2.UserModifiable)
{
prm2.SetValueString(valor); //<= Value not updating!
//prm2.Set(valor); //<= I tried this and didnt work too.
flag = true;
}
}
}
}
}
if (flag)
t.Commit();
else
t.Dispose();
}
}
Solved! Go to Solution.