Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Center of Gravity

API and Macros

Center of Gravity

by  linqur  Posted    (Edited  )
Dim swApp As Object
Dim ModelDoc As Object
Dim Point As Object
Dim Sketch As Object
Dim status As Long

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set ModelDoc = swApp.ActiveDoc
MassProp = ModelDoc.GetMassProperties2(status)
ModelDoc.Insert3DSketch2 (True)
Set Sketch = ModelDoc.GetActiveSketch2
ModelDoc.SetAddToDB (True)
Set Point = ModelDoc.CreatePoint2(MassProp(0), MassProp(1), MassProp(2))
ModelDoc.SetAddToDB (False)
ModelDoc.Insert3DSketch2 (True)
Sketch.Name = "COG " & Format$(Now, "dd.mm.yyyy hh:mm:ss")
ModelDoc.EditRebuild

End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search