Let’s say you want to have the center of gravity to be plotted onto your drawing file (idw file) so that you could keep a documentation of it. What you can do is to create a macro where the program automates the generation of workpoint based on the properties of the mass of the assembly document and or the part document. After running the macro, create a new drawing (idw file) and get the base view of that document. Make sure that in the display options that the User Work Features are checked. Now, the question that you probably have in mind is what if I have other work features that I do not want to be shown? What you just do is to hide the other work features manually by expanding a certain view in the browser tree. It’s just like hiding parts within an assembly environment.

Here’s the macro that I’ve created using the Visual Basic Editor within Autodesk Inventor 11.


Public Sub Cog( )

Dim oAssemblyDoc As AssemblyDocument
Set oAssemblyDoc = ThisApplication.ActiveDocument

' Set a reference to the mass properties object.
Dim oMassProps As MassProperties
Set oMassProps = oAssemblyDoc.ComponentDefinition.MassProperties

'x y and z coordinates of the COG
Dim X
Dim Y
Dim Z

'Setting the values for x, y and z coordinates of COG
X = oMassProps.CenterOfMass.X
Y = oMassProps.CenterOfMass.Y
Z = oMassProps.CenterOfMass.Z

Dim oTrans As TransientGeometry
Set oTrans = ThisApplication.TransientGeometry

Dim oPnt As Point
Set oPnt = oTrans.CreatePoint(X, Y, Z)

Dim oWorkPoint1 As WorkPoint
Set oWorkPoint1 =
oAssemblyDoc.ComponentDefinition.WorkPoints.AddFixed(oPnt, False)

End Sub

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Simpy
  • Spurl
  • YahooMyWeb
Your Ad Here

3 Responses to “Center of Gravity for Autodesk Inventor”

  1. Martin
    January 19th, 2007 at 6:07 pm

    Hi

    This macro doesn’t work on my computer.
    I get: Run-time error ‘13′: Type mismatch

    Why? I’m no good at programing so if you know what the problem is I would be very grateful if could solve it for me. I need the COG on the 2D drawing due to issues regarding lifting.

    -Martin

  2. Dong
    April 20th, 2007 at 6:41 am

    Hi

    This macro doesn’t work on my computer.
    I get: Run-time error ‘13′: Type mismatch
    can you tell me how to figure out that
    Thanks
    Dong

  3. Patrick
    October 10th, 2007 at 11:12 pm

    You need to remove the CR after the Set oWorkPoint1 =
    to have the oAssemblyDoc.ComponentDefinition.WorkPoints.AddFixed(oPnt, False)
    On the same line.
    It works fine for me in 2008

Leave a Reply

Text Link Ads

Recommended Websites



Latest Products

Karla Redor


Blogging live via Paranaque City since 2001. A 20-something graduate of DLSU-Manila. An engineer, amateur photographer, graphic and layout artist. Plays the guitar. Always thought to belong to a certain band. Almost got stuck in a mosh pit but rarely in the mush pit. Coffee lover. Former gig-a-holic. Asteeg!

View Karla Vanessa Redor's profile on LinkedIn

Powered by WordPress - WordPress Blogs Directory

Featured at

Subscribe

Personal - Top Blogs Philippines

Recent Entries