API:how to get the bom tables of a view?

Discussion in 'SolidWorks' started by shan3981, May 16, 2006.

  1. shan3981

    shan3981 Guest

    Now I use VC++ 6.0 and Solidworks 2005 SP5.0 to develop a solidworks
    integration, but I got a problem: Suppose there is a drawing which
    contains only one view, then in the solidworks menu, execute
    Insert>>Tables>>Bill of materials, select current view and press OK,
    add a BOM table(Annotation Table) for the view, so how can I use SDK(SW
    API) to get the Bom table of the view, that is to say I want to get all
    the Bom tables of view by SW api.

    Thanks,
     
    shan3981, May 16, 2006
    #1
  2. shan3981

    CS Guest

    Views have to be associated with a BOM it is a property of the view.
    Creating a BOM off of a view as you describe doesn't link the view to
    the BOM. You can check for the connection.
    this is VB code but the C++



    status = View->GetKeepLinkedToBOMName ( &Name)
    status = View->GetKeepLinkedToBOM ( &Linked)

    Then you can recurse the drawing for the BOM or possibly select by
    name.
    use the following example from the help

    'Get Table Annotation and Contents Example (VB)'

    This is written in VB but the concepts are the same nomatter what
    language you are using.
     
    CS, May 16, 2006
    #2
  3. shan3981

    shan3981 Guest

    Ok. Now we have got the BOM Table's name of the selected view. But the
    problem is: how do we get the content of the BOM table through the
    table's name? For example: a drawing file has 2 sheets, sheet-1 and
    sheet-2, and sheet-1 has 3 views, view-1, view-2, view-3, and each view
    has a BOM table, BOM Table-1, BOM Table-2, BOM Table-3. Now we select
    view-2 of sheet-1, the BOM table of this view is BOM Table-2, and as
    you said, we can get the BOM Name of the view. But we don't know how to
    get the content of the BOM table through the table's name. We get the
    content with the following code:
    CComPtr<ISheet> iSheet;
    DrawingDoc->IGetCurrentSheet(&iSheet);
    CComPtr<IView> iView1, iView2;
    DrawingDoc->IGetFirstView(&iView1);
    CComPtr<ITableAnnotation> iTableAnt;
    iView1->GetFirstTableAnnotation(&iTableAnt);
    while(iTableAnt != NULL)
    {// this loop can get all the BOM Table of this sheet. but we can get
    selected view's BOM Table. That's the problem!
    CComBSTR strTableTitle;
    iTableAnt->get_Title(&strTableTitle); //this title we get is "BOM
    Table", but not "BOM-1", "BOM-2", or "BOM-3";
    long lTableType;
    iTableAnt->get_Type(&lTableType);
    if (lTableType == swTableAnnotation_BillOfMaterials)
    {
    ......//we can get the content.
    }
    else
    {
    CComPtr<ITableAnnotation> iTableAnt2;
    iTableAnt->GetNext(&iTableAnt2);
    iTableAnt = iTableAnt2;
    if(iTableAnt2 != NULL) iTableAnt2.Release();
    }
    if (iTableAnt != NULL) iTableAnt.Release();

    iView1->IGetNextView(&iView2);
    iView2->GetFirstTableAnnotation(&iTableAnt);

    Now iTableAnt == NULL, does it mean that we cannot get the BOM table of
    the view2? But actually, we have already get it for view1. Am i right,
    or I use the incorrect method?.

    This while loop can get all the BOM Table of this sheet. but we can get
    selected view's BOM Table. That's the problem! So what i want to know
    is that how i get the content of view2's BOM table?
     
    shan3981, May 17, 2006
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.