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

Accessing BOM Quantity Type Through Apprentice?

ckeveryga
Advocate

Accessing BOM Quantity Type Through Apprentice?

ckeveryga
Advocate
Advocate

I have a program that loops through an assembly using component occurrences in Inventor. The following code to access the BOM Quantity Type works fine in Inventor: 

 

oOcc.Definition.BOMQuantity.GetBaseQuantity(out qType, out qQTY);

 

When I try to run the same code using Apprentice, I get the following error: (Exception from HRESULT: 0x80004001 (E_NOTIMPL))

 

Does anyone know if it is possible to access this property through apprentice? I have been able to access all other properties in the same way that I would with Inventor, until this error. 

 

Relevant section of code:

 

 

public void Loop(ComponentOccurrence oOcc)
{

BOMQuantityTypeEnum qType;
object qQTY;

oOcc.Definition.BOMQuantity.GetBaseQuantity(out qType, out qQTY);

}

 

 

C# as programming language

Autodesk Inventor 2019, Build: 330, Release: 2019.4.1

0 Likes
Reply
Accepted solutions (1)
970 Views
3 Replies
Replies (3)

tonythm
Advocate
Advocate

Hi @ckeveryga 

 

I have another way, you can refer. I use excel VBA to run with Inventor. I check QTY follow part number, before that i has QTY in excel, after that i place part in assy and check QTY them in BOM Inventor with excel.

If you more learn, please let me know.

Sub CheckQTY()
    Dim oWkbk As Workbook
    Set oWkbk = ThisWorkbook
    Dim oSheet As Worksheet
    Set oSheet = oWkbk.ActiveSheet
    Dim oInv As Inventor.Application
    Set oInv = GetObject(, "Inventor.Application")
    Dim oDoc As Document
    Set oDoc = oInv.ActiveDocument
    ' Set a reference to the assembly document.
    ' This assumes an assembly document is active.
    Dim oAssy As AssemblyDocument
    Set oAssy = oInv.ActiveDocument
    Dim sParamRange As String
        sParamRange = "A44:A200"
    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    oBOM.StructuredViewEnabled = True
    oBOM.StructuredViewFirstLevelOnly = True ' Display First level
    oBOM.StructuredViewMinimumDigits = 3
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
    Dim i As Integer
    For i = 1 To oBOMView.BOMRows.Count
        Dim oRow As BOMRow
        Set oRow = oBOMView.BOMRows.Item(i)
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)
        Dim oPartNumProperty As Property
        Set oPartNumProperty = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number")
        
        Dim oCell As Range
        For Each oCell In oSheet.Range(sParamRange)
            'If oCell.Value = oPartNumProperty.Value Then
            'oRow.ItemNumber = oCell.Offset(0, 1).Value
            'End If
            If oCell.Value = oPartNumProperty.Value Then
                If oCell.Offset(0, 2).Value = oRow.ItemQuantity Then
                oCell.Offset(0, 2).Interior.Color = RGB(0, 176, 240)
                Else
                oCell.Offset(0, 2).Interior.Color = RGB(255, 0, 0)
                End If
            End If
        Next oCell
    Next
    Range("A40").Select
    MsgBox ("Done!")
    oWkbk.Save
End Sub

 

0 Likes

ckeveryga
Advocate
Advocate

@tonythm thanks for the reply. 

 

The reason I need to find the QTY Type using apprentice, is I have created a program outside of inventor that opens inventor in the background and exports multiple BOM's and drawings specific to my company's workflow. I would like to open apprentice instead of inventor as it is much faster for accessing part properties. 

 

I am currently able to access the QTY Type through Inventor (external program or VBA), but I cannot translate the same code to apprentice. 

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@ckeveryga,

 

On running below code, throws System.NotImplementedException: 'Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))' error. It means that method is not implemented in apprentice.

 

oOcc.Definition.BOMQuantity.GetBaseQuantity(out qType, out qQTY);

 

The API exposed by Apprentice is a subset of the complete Autodesk Inventor API. Apprentice provides access to file references, assembly structure, B-Rep, geometry, attributes, render styles, and document properties. Access to the assembly structure, B-Rep, geometry, and render styles is read-only. Access to file references, attributes, and document properties is read and write.

 

The primary differences between Autodesk Inventor and Apprentice are in the Application and Document objects. The objects that represent the Application and Document are completely different in Autodesk Inventor and Apprentice. The Apprentice Application object is called ApprenticeServerComponent. It supports a much more limited API than the Inventor Application object. In Apprentice there isn't a Documents collection.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes