private IBody2[] CreateFillets(ISldWorks app, List <object> dispatches, double radius, bool isPreview, out IReadOnlyList <IFace2> filletFaces)
        {
            if (dispatches == null)
            {
                throw new UserErrorException("Select entities to add fillets to");
            }

            if (radius <= 0)
            {
                throw new UserErrorException("Specify radius more than zero");
            }

            var bodies       = new List <IBody2>();
            var createdFaces = new List <IFace2>();

            var entGroups = dispatches.GroupBy(d => GetBody(d));

            var trackCookie = -1;

            if (isPreview)
            {
                trackCookie = app.RegisterTrackingDefinition(TRACKING_DEFINITION_NAME);
            }

            foreach (var entGroup in entGroups)
            {
                var edges = new List <IEdge>();

                var body = entGroup.Key;

                foreach (var ent in entGroup)
                {
                    object[] entEdges = null;

                    if (ent is IBody2)
                    {
                        entEdges = (ent as IBody2).GetEdges() as object[];
                    }
                    else if (ent is IFace2)
                    {
                        entEdges = (ent as IFace2).GetEdges() as object[];
                    }
                    else if (ent is IEdge)
                    {
                        entEdges = new object[] { ent as IEdge };
                    }
                    else if (ent is IVertex)
                    {
                        entEdges = (ent as IVertex).GetEdges() as object[];
                    }

                    if (entEdges != null)
                    {
                        edges.AddRange(entEdges.Cast <IEdge>().Except(edges));
                    }
                }

                if (isPreview)
                {
                    CreateBodyForPreview(trackCookie, ref edges, ref body);
                }

                if (body.GetType() != (int)swBodyType_e.swSolidBody)
                {
                    throw new UserErrorException("Fillet can only be added to solid bodies");
                }

                var faces = body.AddConstantFillets(radius, edges.ToArray()) as object[];

                if (faces != null && faces.Any())
                {
                    createdFaces.AddRange(faces.Cast <IFace2>());
                }
                else
                {
                    throw new UserErrorException("Failed to create fillet for specified entities due to geometrical conditions");
                }

                bodies.Add(body);
            }

            filletFaces = createdFaces;

            return(bodies.ToArray());
        }