I guess you can tell I am under a shelter in place order. I am trying to do some programming that I have needed to do for a while. This is the perfect time! No interruptions.
I am trying to measure two entities - a face and the front plane. I have:
- Confirmed that I actually have those entities selected in my code.
- Confirm that I can actually do a measurement between the two entities by selecting the front plane in the feature tree and selecting the face in the viewport.
I get -1's for everything and my "result" below is false. Indicate that these are not valid entities, yet I can get the result manually.
Measure measure = part.model.Extension.CreateMeasure();
object selectionObjects = new object;
selectionObjects = biggestFace;
selectionObjects = frontPlane.SolidWorksFeature;
bool result = measure.Calculate(selectionObjects);
var distance = measure.Distance;
None of the examples I have found use measure.calculate but use more complicated ways. There is one example that shows how to measure by using coordinates that would require either knowing the coordinates ahead of time or using mouse input. This wouldn't work in my case. I need this totally hands free.
According to the docs you can give calculate an array of objects that it can calculate. It doesn't specify what the entities need to be to be valid. I am assuming faces, bodies, features, sketch entities, planes and anything else measure can work with.
Am I looking at this too simply?
What am I not doing or doing wrong?