Hello,
I am building a macro, and a part of that macro has to determine the distance from a specific plane to the furthest point of any solid body that is in the model. Here's a simplified screenshot to help visualize the problem:
The real difficulty here is that there might be all sorts of solid bodies, not necessarily the one depicted in the screenshot. There might be multiple bodies as well, and they might be moved, rotated, re-scaled too, so binding the macro to follow a specific point or edge will not work.
The best "solution" I found so far is using that macro to create an offset plane from that main plane, use it surface-cut half of the body, and then advance the offset plane by small steps until surface cut fails, using the latest offset distance as the number I'm looking for. As you can imagine, this is neither practical, nor accurate - I need an accurate solution that works in a single rebuild cycle, not a dozen.
I looked into Bounding Box functionality, but it is very heavy on performance, and isn't really convenient for this challenge.
Ideally, I want to write a single function, which, when called, returns the distance from the selected plane to that furthest point on any solid body in the model. Using auto-generated sketches or other kinds of reference geometry is fine, as long as it doesn't add extra an rebuild cycle, and doesn't slow down the performance of the macro. Can anybody give any ideas how to do this?
P.S. I forgot to say that I have thought of another promising method - create a Boss Extrude feature from that reference plane, with depth set to "Through All", without merging, then measure the height of this extrusion, and finally delete it. However, Through All option doesn't provide a height in a number, so the usual myDimension = Part.Parameter("D1@Boss-Extrude1") won't work.
SolidworksApi macros