Keaton Weir-McPherson

Way(s) to create and use curves as safe entities

Discussion created by Keaton Weir-McPherson on Dec 29, 2020
Latest reply on Dec 30, 2020 by Artem Taturevych

I am working on a fairly large macro which needs to access data from the underlying curves of the edges on a part bodies. When extracting data from the edges, the IEntity.getSafeEntity command can be used to get a safe copy of the edge which will survive rebuild, and this allows me to access the data from the edge throughout the run of the program. However, this is not true of Curve objects. Calling the IEntity.getSafeEntity function on a curve will not give a safe entity, and so if the curve is accessed later in the program it will create and automation error because the curve has become disconnected. 

I have tried saving the safe edge entity and then just accessing the curve at the instant that I need it, but this causes the same problem.

I have also tried playing with the order in which I saved the safe entities, but if I try to get the safe curve entity from the raw edge (instead of the safe edge) it does not return at all and then crashes SolidWorks (that bug may warrant a separate post or bug report).

What I essentially need is to be able to save a snapshot of the body at the start of the program, so that I can extract the data I need as I need it throughout the program. There are some things I can save numerically at the beginning of the program, such as the coordinates of the vertices and direction vectors of the edges, etc, but curve data is a lot more intricate so duplicating it numerically in a way that I could access later is so far not something I know how to do. For example, I need to be able to call the ICurve.getClosestPointOn and ICurve.getTessPts methods. Replicating the curve to the degree that I can get that data later is not easy I suspect. I could tesselate the curve at the beginning of the program, but ideally I want to be able to pick the resolution of the tessellation after the setup is complete. As for the closestPointOn method, if I were to use tessellated points it would reduce the accuracy of the method which is not ideal.
Is there a way to access a curve as a safe entity so that it will survive rebuilds? Or a workaround which will allow me to access curve data throughout the run of the macro?

Outcomes