def createExportNeuroML2(netParams=None, simConfig=None, reference=None,
    connections=True, stimulations=True, output=False, format='xml'):
    """ Sequence of commands to create and export network to NeuroML2 """
    from . import sim
    import __main__ as top
    if not netParams:
        netParams = top.netParams
    if not simConfig:
        simConfig = top.simConfig
    sim.initialize(netParams, simConfig)
    pops = sim.net.createPops()
    cells = sim.net.createCells()
    conns = sim.net.connectCells()
    stims = sim.net.addStims()
    simData = sim.setupRecording()
    sim.exportNeuroML2(reference, connections, stimulations, format)
    if output:
        return pops, cells, conns, stims, simData
