Override the Quantity of a BOM item

By Adam Nagy

I'm trying to override the Qty column of an McadBOMItem, but it does not work.
McadBOMItem.Quantity = 10 only seems to work if you first override the value through the user interface.

Solution

You need to make sure that AutoCalculateEnabled is set to False before trying to override it:

[CommandMethod("OverrideQuantity")]

public void OverrideQuantity()

{

  AcadApplication acadApp = (AcadApplication)
    Autodesk.AutoCAD.ApplicationServices.
Application.AcadApplication;

 

  McadSymbolBBMgr symMgr =
    acadApp.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr");

 

  McadBOMs symBOMs = symMgr.BOMMgr.GetAllBOMTables(true);

 

  foreach (McadBOM symBOM in symBOMs)

  {

    foreach (McadBOMItem symBOMItem in symBOM.get_Items(true))

    {

      symBOMItem.AutoCalculateEnabled = false;

      symBOMItem.Quantity = 20;

    }

  }

}


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading