Message 1 of 1
AutoCAD Mechanical - GetAllPartReferences causing an error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
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?