Is there any options to get center of face without selecting the face?
I find the way. GetBox() on to face. Then find middle point. Simply.
How can you get the center of a face if it is selected?
Double sectionAxes = swModel.Extension.GetSectionProperties2(currentFace);
MathPoint currentPoint = swMathUtil.CreatePoint(new Double
sectionAxes /*centroid X*/,
sectionAxes /*centroid Y*/,
sectionAxes /*centroid Z*/
2015 SOLIDWORKS API Help - GetSectionProperties2 Method (IModelDocExtension)
This has helped you in finding the answer?
I just wanted to see how your current approach was actually dependent on having the item selected. I see now that this API call requires that the face be selected. I am not aware of a way to get the face centroid without using this API call.
Can't you select the face using IEntity::Select4 and then run IModelDocExtension::GetSectionProperties2? I would be interested in knowing why you don't want to select the face.
SolidWorks API Tutorials
Because it is a resource-intensive operation. If the method is performed for 0,001 seconds, with selecting the face it takes 0.1 second. Now imagine that the method should be run on all surfaces in the complex body.
And if I traverse assembly ...
I am not aware of a way
Keith, what we're talking about in this topic?
Your attempt to patronize me makes no sense, sorry. I gave a straightforward and reasonable answer to your question, not sure what the problem is.
A face centroid and the center of a face's bounding box are not necessarily the same --- I hope you're aware of that.
I'm sorry if hurt you.
But the question was: how to find the center of face without selecting. And you ask why I do not want to selecting
I do not assume that every person who asks how to solve a particular problem knows the best approach to solving that problem. If performance issues caused by selection are your only concern, then try running the program with the document invisible or even with SolidWorks invisible.
As I mentioned, a face's centroid is not the same as the bounding box center. So if you truly need the centroid, IFace2::GetBox is not an option.
Keith Rice is right. The centroid of a face is not equal with the bounding box center.
A quick example I want to give. The centroid of a T profile and square profile is different. The centroids of a triangle and a square are also different.
Detailed examples are available below:
Geometric Centroid of a Cross Section - Structure Free - YouTube
Asymmetric Beam Center of Mass | T, C, and L Beams
Center Of Gravity And Moment Of Inertia
Retrieving data ...