INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login

HANDLE


PASSWORD
Remember Me
Forgot Password?

Come Join Us!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • Turn Off Ad Banners
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...Your site is one of the cleanest and BEST forums that I have seen. I have sent quite a few people your way. Keep up the good work!!!"

Geography

Where in the world do Eng-Tips members come from?

API and Macros

Center of Gravity
Posted: 5 Sep 02

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

Back to SolidWorks 3D CAD products FAQ Index
Back to SolidWorks 3D CAD products Forum
My FAQ Archive
Email This FAQ To A Friend

My Archive