API VBA: Getting BOM Part NO.

Discussion in 'SolidWorks' started by Corey Scheich, Aug 5, 2003.

  1. How do you access the part number that will show up in the BOM for a
    specific component. For example: I am in a drawing, and want to open a
    specific part. Get its part number and search an excel spreadsheet to get
    our database description for that part. Does anyone have a quick example or
    something. Thanks.

    Corey Scheihc
     
    Corey Scheich, Aug 5, 2003
    #1
  2. using solidworks api

    1.drawingdoc::getfirstview "get the first drawing view"
    2.View::Getbomtable "check for a bom table and get it"
    3.view::getnextview "get next view and so on"
    4.View::Getbomtable "check for a bom table and get it"
    5.bomtable::attach3 "you must gain access to the bom in order to read it"
    6.gettotalcolumncount "get number of columns"
    7.gettotalrowcount "get number of rows"
    8.getentrytext "using the Getbomtable object" & "columncount" & "rowcount"
    9.bomtable::detach "release the bom"


    for exp.

    for i = 1 to gettotalcolumncount

    for k = 1 to gettotalrowcount

    mystring = Getbomtable.getentrytext(k,i)

    debug.print mystring

    next k

    next i
     
    Sean Phillips, Aug 13, 2003
    #2
  3. Don't worry I got it.

    Sub GetConfigNameInBOM()

    Dim swApp As SldWorks.SldWorks
    Dim swDoc As SldWorks.ModelDoc2
    Dim Config As SldWorks.configuration
    Dim BOM_Name As String
    Dim ANameOn As Boolean

    Set swApp = Application.SldWorks
    Set swDoc = swApp.ActiveDoc
    Set Config = swDoc.GetActiveConfiguration

    ANameOn = Config.UseAlternateNameInBOM

    If ANameOn Then
    BOM_Name = Config.alternateName
    If BOM_Name = "" Then
    BOM_Name = Config.Name
    End If
    Else
    BOM_Name = swDoc.GetTitle
    End If

    End Sub
     
    Corey Scheich, Aug 13, 2003
    #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.