Duplicate Wall Finish from another Project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to duplicate the finish material from another project, and apply it to the user selected WallType in the current project. I am able to programmatically modify the WallType, however, I can't figure out how to use materials from other projects.
CompoundStructure selectedCS = selectedWall.WallType.GetCompoundStructure();
if (selectedCS == null)
return;
try
{
selectedCS.SetMaterialId(0, materialId);
selectedWall.WallType.SetCompoundStructure(selectedCS);
}
catch (Exception ex)
{
SimpleLog.Log(ex);
}
In order to get the MaterialId from another project, I've tried to duplicate a WallType using Jeremy Tammik's example. However, in this example, the focus is on duplicating the properties, and not on the CompoundStructure.
However, I thought I could still open a WallType from the other document that contains the desired material, and simply use the MaterialId of that WallType.
WallType wallType = null;
FilteredElementCollector wallTypes
= new FilteredElementCollector(docHasFamily)
.OfClass(typeof(WallType));
foreach (WallType wt in wallTypes)
{
string name = wt.Name;
if (name.Equals(wallTypeName))
{
wallType = wt;
break;
}
}
selectedCS.SetMaterialId(0, wallType.GetCompoundStructure().GetLayers()[0].MaterialId);
selectedWall.WallType.SetCompoundStructure(selectedCS);
It doesn't work. So I guess I need to figure out how I can load the material from the other document into my current document.