Hi @stav1233,
As per @jeremy_tammik response above, I have checked and solved the same issue you have using Activate Family Symbol article.
Family Symbols require to be activated for them to be loaded into the document. You should check whether the symbol is active once the transaction starts or right before the transaction commits. Once it is activated the document re/generates it and it gets loaded. If the symbol is inactive, Revit gives you this exception (attached below). See my code snippet of how you can implement the solution provide on @jeremy_tammik article.
// Find a Window type for the new windows
FilteredElementCollector winCollector = new FilteredElementCollector(document);
IList<Element> windowTypes = winCollector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsElementType().ToElements();
FamilySymbol winType = windowTypes.First() as FamilySymbol;
//Level level = myWall.Document.GetElement(myWall.LevelId) as Level;
//XYZ location = new XYZ(-22.6724094227806, 45.595454156592, 3.00196850393702);
double x =2 , y =2, z =2;
//inserts 3 windows
for(int i = 0; i < 3; i++)
{
XYZ location = new XYZ(x, y, z);
Transaction trans = new Transaction(document);
trans.Start("window instance");
//check whether the family symbol is active, if not activate and regenerate
if (!winType.IsActive)
{
winType.Activate();
document.Regenerate();
}
FamilyInstance instance = document.Create.NewFamilyInstance(location, winType, myWall, StructuralType.NonStructural);
x += 3;
y += 3;
trans.Commit();
}
Carol Gitonga,

Developer Advocacy and Support,
ADN Open