Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Frederick_Law
in reply to: NSBowser

If I remember correctly, not all plane creation method works.  Some wrok in part and some work in assembly.  Also what need to be passed are pretty specific type.  This took some trial and error so it may not be to best solution.

This is what I use to create point and planes on COG, VS VB.net Inventor addin:

    Private Sub COGUpdate()
      Dim oWorkPoint As WorkPoint
      Dim oWorkPlane As WorkPlane
      Dim vX, vY, vZ As UnitVector
      Dim oFixedDef As FixedWorkPointDef
      Dim oAssPtDef As AssemblyWorkPointDef
      Dim PointExist As Boolean = False
      Dim COGXYExist As Boolean = False
      Dim COGXZExist As Boolean = False
      Dim COGYZExist As Boolean = False
      Dim oDoc As Document = m_inventorApplication.ActiveDocument
      Dim oCenterOfMass As Point = oDoc.ComponentDefinition.MassProperties.CenterOfMass

      For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
        If oWorkPoint.Name = "COG" Then
          PointExist = True
          If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            oAssPtDef = oWorkPoint.Definition
            oAssPtDef.Point = oCenterOfMass
          ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            oFixedDef = oWorkPoint.Definition
            oFixedDef.Point = oCenterOfMass
          End If
          oDoc.Update()
          Exit For
        End If
      Next

      If Not PointExist Then
        oWorkPoint = oDoc.ComponentDefinition.WorkPoints.AddFixed(oCenterOfMass)
        oWorkPoint.Name = "COG"
      End If

      vX = m_inventorApplication.TransientGeometry.CreateUnitVector(1, 0, 0)
      vY = m_inventorApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
      vZ = m_inventorApplication.TransientGeometry.CreateUnitVector(0, 0, 1)

      For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
        Select Case oWorkPlane.Name
          Case "COG XY"
            oWorkPlane.SetFixed(oWorkPoint.Point, vX, vY)
            COGXYExist = True
            'oWorkPlane.Delete()
          Case "COG XZ"
            oWorkPlane.SetFixed(oWorkPoint.Point, vX, vZ)
            COGXZExist = True
            'oWorkPlane.Delete()
          Case "COG YZ"
            oWorkPlane.SetFixed(oWorkPoint.Point, vY, vZ)
            COGYZExist = True
          Case Else
            Exit Select
            'oWorkPlane.Delete()
        End Select
      Next

      If Not COGXYExist Then
        oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vX, vY)
        oWorkPlane.Name = "COG XY"
      End If
      If Not COGXYExist Then
        oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vX, vZ)
        oWorkPlane.Name = "COG XZ"
      End If
      If Not COGYZExist Then
        oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddFixed(oWorkPoint.Point, vY, vZ)
        oWorkPlane.Name = "COG YZ"
      End If

      oDoc.Update()

    End Sub