0

I am working on a project where I am required to add properties to the materials of an element in revit api I was able to do the task except I could not add the surface pattern color and cut pattern color.

My code is as follows

Color matColor = new Color(Byte.Parse(materials.Red.ToString()), Byte.Parse(materials.Green.ToString()), Byte.Parse(materials.Blue.ToString()));
myMaterial.Color = matColor;
myMaterial.Transparency = 0;
myMaterial.SurfacePatternColor = matColor;
myMaterial.CutPatternColor = matColor;  

Color is applied only to materials color and not to the surface pattern and cut pattern Also I do not get any errors Please guide me as to where I am going wrong

Thank you in advance

JPais
  • 115
  • 2
  • 14

1 Answers1

1

I think it does apply the color, but you forgot to add a pattern. So you now have a color but an empty pattern. Do you want it to be solid? Then I think the following code should work (I have not tested it):

FillPatternElement myFillPattern = new FilteredElementCollector(doc).OfClass(typeof(FillPatternElement)).Cast<FillPatternElement>().First(a => a.Name.Contains("Solid fill"));
myMaterial.SurfacePatternId = myFillPattern.Id;
myMaterial.CutPatternId = myFillPattern.Id;
Jan Buijs
  • 98
  • 1
  • 6