Thank you @TripleM-Dev.net and @naveen.kumar.t.
Me and @sofia_feist implemented a solution that follows your advice.
Here is a possible solution but that still has some flaws:
We were able to successfully retrieve all BuiltInCategory Elements of OST.IOSketchGrid. For the project in case, there were 6 elements retrieved which consisted mostly of levels in the projects. One of these elements is in fact the Active Work Plane Grid. The only problem we have is retrieving just this one element logically.
We ended up setting the grid spacing value for all (in the case of this project 6) elements and this way we are sure that the Work Plane Grid has the spacing we want. This is not an ideal solution but it does the job.
We tried checking all properties of the retrieved elements but there seems to be nothing that could help in selecting the one element that is the current Work Plane Grid by distinguishing it from the other retrived elements.
If anyone has any other suggestion on how to retrieve the Work Plane Grid logically please let us know.
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_IOSSketchGrid);
using (Transaction trans = new Transaction(doc, "Move Module"))
{
trans.Start();
FilteredElementCollector collector = new FilteredElementCollector(doc);
IEnumerable<Element> sketchGrids = collector.WherePasses(filter)
.WhereElementIsNotElementType()
.Where(e => e.get_Parameter(BuiltInParameter.SKETCH_GRID_SPACING_PARAM).HasValue)
.Where(e => e.get_Parameter(BuiltInParameter.SKETCH_GRID_SPACING_PARAM).SetValueString("500"));
trans.Commit();
}
e