The critical current of a model high-temperature superconductor (HTSC) with defects in the form of through holes (antidots) with characteristic sizes on the order of the magnetic-field penetration depth (or larger) is calculated. To this end, subprocesses equivalent to the magnetic-flux trapping by a hole and creation of a vortex near the hole edge are introduced into the model of a layered HTSC. It is shown that account for these subprocesses yields a physical mechanism, which makes it possible to describe correctly the nonmonotonic dependence of the critical current on the antidot characteristic size, which is similar to the experimental one. The calculations are carried out for a pure superconductor and a superconductor with nanoscale pinning centers. It is shown that the presence of nanoscale pinning centers along with antidots does not make qualitative changes in the relationship between the antidot radius and magnetic-flux pinning character and the critical-current behavior in an HTSC.