Goal: For a solved result, take the current selection in the graphics window (of either nodes or elements) and create a copy of the result scoped to this selection.
Code:
selmgr = ExtAPI.SelectionManager
loc = selmgr.CurrentSelection
res = Tree.FirstActiveObject
# verify object is a result or a custom result
isRegularResult = isinstance(res, Ansys.ACT.Automation.Mechanical.Results.Result)
isCustomResult = res.DataModelObjectCategory == DataModelObjectCategory.UserDefinedResult
if (isRegularResult or isCustomResult):
newRes = res.Duplicate()
newRes.ClearGeneratedData()
newRes.Location=loc
newRes.EvaluateAllResults()
else:
print "Selected Object is not a Result!"