The problem is that I can't determine the inner borders for hatching, I added an ObjectIdCollection, which contained all the ObjectIds that I wanted to take into account: text and polylines, but I kept getting an error, or they weren't taken into account and everything inside the outer border was hatching.
hatch.PatternAngle = patternAngle;
hatch.PatternScale = patternScale;
hatch.Layer = LayerHatchName;
hatch.HatchStyle = HatchStyle.Outer;
hatch.SetHatchPattern(patternType, patternName);
ObjectIdCollection boundaryIds = new ObjectIdCollection();
boundaryIds.Add(leftHatchPoly.ObjectId);
hatch.AppendLoop(HatchLoopTypes.External, boundaryIds);
hatch.EvaluateHatch(true);
btr.AppendEntity(hatch);
tr.AddNewlyCreatedDBObject(hatch, true);
I know that I'm passing a new ObjectIdCollection here, and that it has only one object. This code is for an example of how hatching is used and the only working option. Now it looks like this enter image description here