AutoCAD Mechanical - GetAllPartReferences causing an error

AutoCAD Mechanical - GetAllPartReferences causing an error

alain_miltenburg
Advocate Advocate
1,084 Views
0 Replies
Message 1 of 1

AutoCAD Mechanical - GetAllPartReferences causing an error

alain_miltenburg
Advocate
Advocate

We have developed an VBA application for generating Part References from Dynamic Blocks. The program works flawlessly when run from the VBA editor. However we are getting the following error when the application is run using -VBARUN:

 

GetAllPartReferences error.PNG

 

 

We have managed to isolate the problem into the code below. Important: Create one Part References and make 2 copies using the copy command before you start.

 

Option Explicit

Sub Main()
    Dim SymbolBBMgr As McadSymbolBBMgr: Set SymbolBBMgr = ThisDrawing.Application.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr")
    Dim BOMMgr As McadBOMMgr: Set BOMMgr = SymbolBBMgr.BOMMgr
    Dim AllPartReferences As McadPartReferences
    
    Set AllPartReferences = BOMMgr.GetAllPartReferences
    
    AllPartReferences(1).Delete
    AllPartReferences(2).Delete
  
    Set AllPartReferences = BOMMgr.GetAllPartReferences
    
    ThisDrawing.Application.Update
End Sub

When this code is run from the VBA editor it runs fine. The second GetAllPartReferences results in a collection with one element, as you would expect. Running the code using -VBARUN will result in the aforementioned error message.

What is going on here? Are we missing something? Or is this a bug in the API?

 

0 Likes
1,085 Views
0 Replies
Replies (0)