Are the objects copies of an existing object that is already attached to the Process Flow (i.e. you vary the number of objects in a group)? In that case the copies will also be attached to the Process Flow. So if possible, I would use this approach.
If you need to attach completely new objects you can use the same code that gets executed when using the GUI. The usual caveat of no guaranteed compabitility when using the "function_s" command applies. (I also don't know what the "activedocumentnode()" that gets passed in as the fourth parameter is for. In tests it doesn't seem to be necessary)
treenode processFlow = Model.find("...");
Object obj = ...;
function_s(processFlow, "attachObject", obj, activedocumentnode());
obj.applyProperties("ProcessFlows");