• Blog posts


    by Luke Davenport

    How do you add the centre of gravity into your Inventor Publisher documents? Mass properties and densities are not imported into Publisher, so to reference the C of G you have to produce a little work around. One method that works quite nicely (and doesn’t involve having to ask your Inventor user to tell you the X Y Z co-ordinates of the C of G) is to automatically run an iLogic rule that places a dummy part in the C of G location when you save you Inventor assembly. Here is the full iLogic code for this, and check out the video for more information:


    Full iLogic code :

    'Start of iLogic code

    'Delete the C of G part if already present 


    doc = ThisDoc.Document

    Dim compOcc As ComponentOccurrence = Component.InventorComponent("COFG PART:1")



    End Try

    'Add C Of G part


    pt = iProperties.CenterOfGravity


    'Add custom iproperties with co-ordinates of C of G

    iProperties.Value("Custom", "cx")=pt.X


    iProperties.Value("Custom", "cy")=pt.Y


    iProperties.Value("Custom", "cz")=pt.Z


    'Correct units

    COFGX=iProperties.Value("Custom", "cx")/10

    COFGY=iProperties.Value("Custom", "cy")/10

    COFGZ=iProperties.Value("Custom", "cz")/10


    'set a reference to the assembly component definintion.

    'this assumes an assembly document is open.

    Dim oAsmCompDef As AssemblyComponentDefinition

    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition


    'set a reference to the transient geometry object.

    Dim oTG As TransientGeometry

    oTG = ThisApplication.TransientGeometry

    ' Create a  placement matrix

    Dim oMatrix As Matrix

    oMatrix = oTG.CreateMatrix 

    'set the matrix coordinates

    oMatrix.SetTranslation(oTG.CreateVector(COFGX, COFGY, COFGZ))


    ' Add the C of G part in correct location

    Dim oOcc As ComponentOccurrence

    oOcc = oAsmCompDef.Occurrences.Add("C:\CAD WIP\COFG PART.ipt", oMatrix)


    'Show message box if there are no components in assembly

    MessageBox.Show("No C of G Available - Please insert components!", "Error")

    End Try

    End of iLogic code