Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API PROBLEM - HOW TO GET MASS PROPERTIES

Status
Not open for further replies.

davidetwo

Computer
Joined
Dec 7, 2004
Messages
2
Location
IT
Hi all!
I hope you can help me about a problem on programming solidworks.I'm sorry if my english is not clear: i'm italian.
I need to retrieve the "center of mass" from a partdoc or a subassembly in an assembly document.
Possibilities are two:
1 - Select a component or a subassembly in an assembly document and retrieve center of mass and the mass.
2 - Select more than one part or subassembly and get the "common center of mass" of the objects.
I tried to use examples on the API-help of SW and on the solidworks site's but at least i was able to get the center of mass on selection of one component.The data i have retrieved are similar to those who are retrieved from the solidworks toolsmassprops, but it can be ok!
The problem is the multiple selection:i get points that are totally wrong.
I hope you understand and that someone can help me to solve this problem.
Thank you!Bye
 
There is one way to get around this. Make a loop that gets the centers of mass for the selected components one by one and then read them into an array. From there you can easily calculate the center of mass of the group.
 
Ok i've got the center of mass of all parts.Now how can i calculate the center of the group?
 
XCG= SUM(xcg(i)*mass(i))/SUM(mass(i)
YCG= SUM(ycg(i)*mass(i))/SUM(mass(i)
ZCG= SUM(zcg(i)*mass(i))/SUM(mass(i)

But I'm getting the feeling that you're going in a hard way.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top