diff --git a/src/DynareMain.cc b/src/DynareMain.cc
index 9429c978e5a81678eb22e1f5aed3335066e2a463..d9621dc4a241a2cac094a30e0f2b392c6b4774a7 100644
--- a/src/DynareMain.cc
+++ b/src/DynareMain.cc
@@ -145,6 +145,7 @@ main(int argc, char **argv)
   bool minimal_workspace = false;
   bool compute_xrefs = false;
   bool transform_unary_ops = false;
+  bool gui = false;
   string exclude_eqs, include_eqs;
   vector<pair<string, string>> defines;
   vector<filesystem::path> paths;
@@ -390,6 +391,8 @@ main(int argc, char **argv)
         }
       else if (s == "onlymodel")
         onlymodel = true;
+      else if (s == "gui")
+        gui = true;
       else
         {
           cerr << "Unknown option: " << s << endl;
@@ -471,7 +474,7 @@ main(int argc, char **argv)
   else
     mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
                                nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs,
-                               mexext, matlabroot, dynareroot, onlymodel);
+                               mexext, matlabroot, dynareroot, onlymodel, gui);
 
   cout << "Preprocessing completed." << endl;
   return EXIT_SUCCESS;
diff --git a/src/ModFile.cc b/src/ModFile.cc
index 293a8980f710af60456444936e35b8227d962774..4b225a1f8443edee0399462a982d8a94dedbbb60 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -839,7 +839,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
                           bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
                           const string &mexext,
                           const filesystem::path &matlabroot,
-                          const filesystem::path &dynareroot, bool onlymodel) const
+                          const filesystem::path &dynareroot, bool onlymodel, bool gui) const
 {
   bool hasModelChanged = !dynamic_model.isChecksumMatching(basename, block) || !check_model_changes;
   if (hasModelChanged)
@@ -1024,7 +1024,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
         static_model.writeOutput(mOutputFile, block);
     }
 
-  if (onlymodel)
+  if (onlymodel || gui)
     for (const auto &statement : statements)
       {
         /* Special treatment for initval block: insert initial values for the
@@ -1054,6 +1054,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
 
         if (auto sgs = dynamic_cast<ShockGroupsStatement *>(statement.get()); sgs)
           sgs->writeOutput(mOutputFile, basename, minimal_workspace);
+
+        if (gui)
+          if (auto it = dynamic_cast<NativeStatement *>(statement.get()); it)
+            it->writeOutput(mOutputFile, basename, minimal_workspace);
       }
   else
     {
diff --git a/src/ModFile.hh b/src/ModFile.hh
index 7eaa88b376c45c31fec271a6fb318367b2eb5b34..ae53b468d25a065cf2786fee787f676adfc2b716 100644
--- a/src/ModFile.hh
+++ b/src/ModFile.hh
@@ -168,7 +168,7 @@ public:
                         bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
                         bool check_model_changes, bool minimal_workspace, bool compute_xrefs,
                         const string &mexext, const filesystem::path &matlabroot,
-                        const filesystem::path &dynareroot, bool onlymodel) const;
+                        const filesystem::path &dynareroot, bool onlymodel, bool gui) const;
   void writeExternalFiles(const string &basename, LanguageOutputType language) const;
   void writeExternalFilesJulia(const string &basename) const;