If you make use of the Revit API...sure.
In the GUI you would export a file to IFC and possibly make some settings.
Similar steps should be followed in the code.
A good source for programming the Revit API is the buildingcoder website.
As a note these kind of questions are better asked in the Revit API forum.
Louis
Please mention Revit version, especially when uploading Revit files.
Yes, indeed, the Revit API forum is the place to go.
Answered the same question here:
https://forums.autodesk.com/t5/revit-api-forum/export-revit-file-to-ifc-using-vb-net-c/m-p/7570107
Cheers,
Jeremy