AnsweredAssumed Answered

What is the fastest way to measure cross-sectional area of a solid body through API?

Question asked by J. R. on Nov 24, 2018
Latest reply on Nov 28, 2018 by J. R.



In a VB.NET application I'm making, which interfaces with Solidworks API, the most noticeable performance drop comes from measuring cross-sectional areas of a solid body. My application has to make hundreds of such measurements at certain distance intervals (sort of like cutting a body into slices and measuring the area of each slice). The way I do it right now is slow and inefficient, but it is the only way I could come up with:

1. Making a Temporary Body copy of the body I want to measure;

2. Creating another "Cut" surface, positioning it at the right offset, and using Operations2 with the Cut surface to slice off part of that first Temporary Body;

3. Finding out which resulting face(s) coincident with the Cut surface, measuring it's area (or adding the areas if there are multiple surfaces that result after the cut);

4. Discarding all the bodies, surfaces, and then repeating it all over again, but this time advancing the Cut surface by an interval to make the next slice.


Thing is, even thought I'm doing this purely through Temporary Bodies (no sketches, no planes, no features), it is still very slow. Cutting even a simple body into, say, 100 slices, takes about 2.6 seconds, which is unforgivably slow. No wonder - after all, I'm copying, creating, combining and then deleting bodies, which is a lot of operations.


I am sure there must be a better, faster way. I looked through the API knowledge base, but there are so many API calls and combinations of them, that I'm not really sure what to look for. Google searches were fruitless.


Can someone advise, please?

Thank you.