Programmatically making M2Doc generated docs

Trying to make multiple docs and replacing a single variable in each, the goal is to do so without going through the template and renaming the element being used can creating a new doc to save. Was planning on doing so via python scripts but is there a way to do so via the command line? (open to other suggestions)

Thank you :slight_smile:

There is a Capella command line tool to launch the generation of a .genconf file in the M2Doc Capella extensions. It works like the Python4Capella one if you have a Team for Capella environment.

You can launch it with the following command:

capella.exe -nosplash -consolelog -application org.polarsys.capella.core.commandline.core -appid org.obeonetwork.capella.m2doc.commandline -filepath project/myGeneration.genconf -data ./workspace -outputfolder /project/generated -forceoutputfoldercreation

If you want to generate documents programmatically you can also have a look at the documentation.

Thank you for the command. I was looking at the documentation for generating automatically but I was confused on how to use it through java as it is in the documentation. I was trying to figure out how to develop in java, is there an easier way to learn to programmatically create the generation code, because I’m not sure how to use the java code given in the documentation. May be a simple answer but it has me quite confused.

Also, when I run that command, the Capella terminal window pops-up but shuts-down after a second after it tries generating. Is there somewhere I can see the error log to see what is causing it to close/crash?

If you want to launch your generation form a .genconf file you might also use this method as a starting point.

The log should be in the console when you use -consolelog… but you should also find a file in the workspace workspace/.metadata/.log.

Not sure what to make of this error message, here is the command and log info (I also chan):

capella.exe -nosplash -consolelog -application org.polarsys.capella.core.commandline.core -appid org.obeonetwork.capella.m2doc.commandline -filepath ./workspace/In-Flight Entertainment System With M2Doc/Template LA Complete.genconf -data ./workspace -outputfolder ./workspace/In-Flight Entertainment System With M2Doc/generated -forceoutputfoldercreation

(also tried changing names to avoid spaces in path names):
capella.exe -nosplash -consolelog -application org.polarsys.capella.core.commandline.core -appid org.obeonetwork.capella.m2doc.commandline -filepath C:/Apps/capella/workspace/FES-M2Doc/TemplateLA.getconf -data C:/Apps/capella/workspace/FES-M2Doc -outputfolder C:/Apps/capella/workspace/FES-M2Doc/generated -forceoutputfoldercreation

java.lang.NullPointerException: Cannot invoke “org.obeonetwork.capella.m2doc.commandline.M2DocCommandLinePlugin$Implementation.log(Object)” because the return value of “org.obeonetwork.capella.m2doc.commandline.M2DocCommandLinePlugin.getPlugin()” is null

Do you have the complete stack trace ? There is an exception because we try to log something…