Ungroup after Attatched Detail Group Show

Hello everyone!
I´ve been having some issues getting dynamo to ungroup a group containning an Attatched Detail Group. This is the Group after running the graph without trying to ungroup it works just fine, plus if i ungroup it with dynamo or manually after the graph is done there is no problem.

However if i ungroup it within the same graph it appears to wait until graph is done to apply ShowAllAttachedDetailGroups to the view so it ungroups without the Attached Detail Group

Python Script

try to ungroup Attatched Detail Group first, then ungroup the Model Group

import clr
import sys
import System
from Autodesk.DesignScript.Geometry import *

#import Revit API
import Autodesk
from Autodesk.Revit.DB import *

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

toList = lambda x : x if hasattr(x, '__iter__') else [x]
lstOfgroup = toList(UnwrapElement(IN[0]))
activeView = doc.ActiveView
#Do some action in a Transaction
out = []
for gp in lstOfgroup:
	temp = []
	#ungrpoup Attached Detail Group
	filterG = System.Predicate[System.Object](lambda x : x.AttachedParentId == gp.Id)
	gpDetails = FilteredElementCollector(doc, activeView.Id).OfCategory(BuiltInCategory.OST_IOSAttachedDetailGroups).ToElements().FindAll(filterG)
	for gpDetail in gpDetails:
		ungroupDet_ids = gpDetail.UngroupMembers()
		temp.extend([doc.GetElement(xId) for xId in ungroupDet_ids])
	#ungrpoup Model Group
	ungroupids = gp.UngroupMembers()
	temp.extend([doc.GetElement(xId) for xId in ungroupids])

OUT = out

Thank You! this is perfect!