private bool WriteParameter(ParameterMapProperties pmp, SpatialElementProperties sep, List <Element> revitElements) { bool result = false; try { SpatialElement spatialElement = sep.ElementObj; if (null != spatialElement) { Parameter sParam = spatialElement.LookupParameter(pmp.SpatialParamName); if (null != sParam) { using (Transaction trans = new Transaction(m_doc)) { trans.Start("Write Parameters"); try { foreach (Element re in revitElements) { if (re.GroupId != ElementId.InvalidElementId) { groupExist = true; continue; } //elements in group Parameter rParam = re.LookupParameter(pmp.RevitParamName); if (null == rParam) { ElementType elementType = m_doc.GetElement(re.GetTypeId()) as ElementType; if (null != elementType) { rParam = elementType.LookupParameter(pmp.RevitParamName); } } if (null != rParam) { if (rParam.IsReadOnly) { continue; } switch (rParam.StorageType) { case StorageType.Double: try { rParam.Set(sParam.AsDouble()); } catch { } break; case StorageType.ElementId: try { rParam.Set(sParam.AsElementId()); } catch { } break; case StorageType.Integer: try { rParam.Set(sParam.AsInteger()); } catch { } break; case StorageType.String: try { rParam.Set(sParam.AsString()); } catch { } break; } } } trans.Commit(); } catch (Exception ex) { string message = ex.Message; trans.RollBack(); } } result = true; } } } catch (Exception ex) { errorMessages.AppendLine("Cannot write parameter values of family instances inside - " + sep.ElementObj.Number + " : " + sep.ElementObj.Name); errorMessages.AppendLine(ex.Message); } return(result); }