how to rename line bodies in the Mechanical tree based on their assigned cross-section?
Try using the below code in Mechanical scripting console
linebodies = [child for child in DataModel.GetObjectsByType(DataModelObjectCategory.Body) if child.GeometryType == GeometryType.Line] for linebody in linebodies: linebody.Name = "Beam CS - " + linebody.CrossSectionName