I would like to use Trace Geometric Network in model builder with the option to have a model parameter for the flags (like the flags I add from Utility Network Analyst Toolbar) and return the results as a selection set.
2 Answers
You can not set a flag as a model (or gp tool) parameter. However, you can use a point feature class instead of a set of flags. Therefore if you select some features of that point feature class the tool will just take those selected ones to the account.
So, use "Trace Geometric Network" geoprocessing tool with your model and set the Flags parameter with your point feature layer. This tool returns the result as a selection set.
i was able to do this. I added Trace Geometric Network tool to model builder. I set the Flags and Barriers as Feature Sets (also make these Model Parameters) and imported a symbology from my map (important so Coord sys is the same). Then use the Snap tool to snap the Flags and Barriers to lines or devices. I then used Select Data to choose from the trace results and used the Make Feature Layer to create the selection add it to the map. You must make this result a MP and Add to Display. Use your map service as a base map so it projects correctly.
Esri has a good example: http://server.arcgis.com/en/server/latest/publish-services/windows/gp-service-example-geometric-network-trace.htm