I want to have annotations displaying body names with different colors for all the bodies present in my Model
You can use the following code. This code has defined only 7 colors based on the RGB combination. It only works for StandardMKS and StandardNMM unit systems. If you have any other system, you can append that as an if statement.
unit_str = str(ExtAPI.DataModel.Project.UnitSystem) if unit_str.StartsWith('StandardMKS'): length="m" if unit_str.StartsWith("StandardNMM"): length="mm" bodies = Model.Geometry.GetChildren(DataModelObjectCategory.Body, True) r=[255,0,0,255,255,255,0] g=[255,255,255,0,128,255,120] b=[0,255,0,255,0,255,255] a=255 #colors=["Yellow","Cyan","Lime","Pink","Orange","Pale White","Light Blue"] i=0 for body in bodies: label = Graphics.LabelManager.CreateLabel(body) label.Note = body.Name c=body.GetGeoBody().Centroid x=c[0] y=c[1] z=c[2] label.Scoping.XYZ=Point((x,y,z),length) label.Color=Ansys.ACT.Common.Graphics.Color(red=r[i], green=g[i], blue=b[i], alpha=a) label.ShowAlways=True i+=1