Konnichiwa Kandennti-san,
The code is impressive. Particularly, I find the use of measureMgr.getOrientedBoundingBox(clone, vecU, vecV)
very innovative. 👍
However, there are some issues here:
- It is a hard yakka for most of the mortals… particularly those on a wheat diet
- The crucial operations such as measurements in respectable CAD software should be performed at the software's core level.
- Moving such calculations to semi-effective external processes (high-level languages) leads to inefficiencies and inconsistencies, not to mention frustrations… of some.
- I hope that the measurement of the body to a plane combination is only the TF360-mishap in the case code statement.
In this particular case, I used a relatively simple remedy (file:BodyDistance, sketch:CPlane):
- Create a sketch on CPlane
- Draw on it circle profile (CProfile) with a radius order of magnitude higher than the maximum dimension of targetBody.
- Perform the measurement as usual in UI. In the script, use :
- measureResult = app.measureManager.measureMinimumDistance( CProfile, targetBody )
On a side note…
The distance measurements in any CAD software creates the foundation of the whole pyramid of successive processes. The consistency, type range and its speed are a critical determinant of the software. Much more, if the quality and pace of the operation are high enough, the design itself could gain a property of self-awareness, resulting in the interaction with the software to entirely different levels.
So how to improve the process?
The short and straightforward answer is: match an efficient algorithm with optimal utilization of the computing hardware. Just as a mental health exercise (and shaking off the rust from some neurons), please find an outline of such an algorithm for measuring the body's distance to a plane (file BodyDistance).
The draft of steps is as follows (without possible optimizations):
- Create tempPlane_0 perpendicular to CPlane (there are an unlimited possibility here, which one is not essential)
- Project targetBody on the sketch references by tempPlane_0 (call it projection_0)
- Create tempPlane_1 perpendicular to tempPlane_0 (there are an unlimited possibility here, which one is not essential)
- Project projection_0 on the sketch references by tempPlane_1 (call it projection_1). Note that the projection_1 is a projection to a line (1D projection)
- Order the points coordinate (only one, it is 1D set).
- Relate endpoints (coordinates) to CPlane, giving you the maximum and minimum distance of the targetBody to CPlane.

It is worth noting that the most computing-intensive operations (point 2 and 4) can be combined as one algebraic matrix operations. As such, it opens the way to unleash possibilities of parallel processing on CPU or even better on GPU (particularly if the model resides on its memory). Given the current hardware abilities, there is a chance that the speed of the operations would be sufficient to achieve …. a design self-awareness paradigm (e.g. bumping objects).
Regards
MichaelT
MichaelT