SelElementSet m_selection = m_application.ActiveDocument.Selection.Elements;
if (0 == m_selection.Size)
{
MessageBox.Show("Vous devez sélectionner un élément", "rvtAPI_ImageReload");
return;
}
if (1 < m_selection.Size)
{
MessageBox.Show("Vous ne devez sélectionner qu'un seul élément", "rvtAPI_ImageReload");
return;
}
// Find all wall types and their system families (or kinds)
WallType newWallType = null;
foreach (WallType wt in m_doc.WallTypes)
{
string str = wt.Name;
if (str.Contains("panneau"))
{
newWallType = wt;
continue;
}
}
m_application.ActiveDocument.BeginTransaction();
foreach (Autodesk.Revit.Element elem in m_selection)
{
Wall wall = elem as Wall;
WallType oldWallType = wall.WallType;
// change wall type and report the old/new values
wall.WallType = newWallType;
}
m_application.ActiveDocument.EndTransaction();