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





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
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
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