Ansys Employee

The smart variable is compiled data to identify a selection. This means you can't look at any code to see exactly how it works. It is only saved to the script when you save as .scscript format. The .py format is only a text format and so will not save this complied data.

The smart variable, also known as metadata, is very much tied to the curent geometry. Because of this, I personally prefer to get rid of any compiled data so the script is more interchangable with other models. You can do this by setting index selection type:

You can also make sure your script continues by using the return values of previous functions:

result.CreatedPlanes, result.CreatedCurves, result.CreatedBodies, result.CreatedFaces, result.CreatedPlanes[0]

Normally your Body1 and Body2 smart variables would not work interchangeably, because each is tied to the specific body that you then deleted. It is only working because you are clearing everything and each seems to point to the first body.