AnsweredAssumed Answered

Check if sheet bodies are present in an assembly

Question asked by Vera Skorkovska on Mar 23, 2018
Latest reply on Mar 27, 2018 by Vera Skorkovska

Hello,

I am using the C# Solidworks API to write a plugin which (among other things) exports the parts as .3mf files. For parts that contain sheet bodies, it does not export the whole model if the bodies are not solid, but the solid bodies are exported correctly. Is there a way to reliably tell if there are any sheet non-solid bodies present so that I could export only these parts as .stl? I tried several ways to achieve this but I wasn't able to distinguish between these two.

 

Using the following code, all the bodies are recognized as of type swBodyType_e.swSheetBody, even though some of the bodies are solid and are exported into .3mf correctly.

 

                var bodies = partDoc.GetBodies2((int)swBodyType_e.swAllBodies, false);
                if (bodies != null)
                {
                    foreach (var x in bodies)
                    {
                        Body2 body = x as Body2;
                        if (body != null)
                        {
                            int bodyType = body.GetType();
                            if (bodyType == (int)swBodyType_e.swSheetBody)
                            {
                                cSheetbody++;
                            }
                            else if (bodyType == (int)swBodyType_e.swSolidBody)
                            {
                                cSolidBody++;
                            }
                        }
                    }

 

Any help would be appreciated. Thanks.

Outcomes