Hi,
As Naveen pointed out you have to pass the Id of the fillpatternelement(fpe).
To set the solid fill style (surface pattern style) you can use the GetFillPattern() method to get the FillPattern associated to this element.
For example, below the inserted code (macro) i choose to set the pattern style to "Crosshatch".
Change whatever pattern style you want to use; only those who are currently available in the project document.
Did you try this something like this?
I hope this is useful for you.
public void FillPatternWalls()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = this.ActiveUIDocument.Document;
var patternCollector = new FilteredElementCollector(doc);
patternCollector.OfClass(typeof(FillPatternElement));
// replace "Crosshatch" with another fill pattern style you want
FillPatternElement fpe = patternCollector.ToElements().Cast<FillPatternElement>().First(x => x.GetFillPattern().Name == "Crosshatch");
OverrideGraphicSettings ogs = new OverrideGraphicSettings();
ogs.SetProjectionFillPatternId(fpe.Id);
ogs.SetProjectionFillPatternVisible(true);
ogs.SetProjectionFillColor(new Color(255, 0, 255));
using (Transaction t = new Transaction(doc, "Set Fill Pattern Walls"))
{
t.Start();
foreach (Element wall in new FilteredElementCollector(doc,doc.ActiveView.Id).OfClass(typeof(Wall)))
{
doc.ActiveView.SetElementOverrides(wall.Id, ogs);
}
t.Commit();
}
uidoc.RefreshActiveView();
}