API - BOM Tables and Formatting

Discussion in 'SolidWorks' started by Len K. Mar, Jul 30, 2004.

  1. Len K. Mar

    Len K. Mar Guest

    Hi,

    I need some help.

    My SW API skills are just short of being dangerous to anyone standing
    in a 20 ft. radius. I believe this will be an easy question to answer
    :)

    I have a 3rd party application that generates a script to create and
    populate the revision block.

    The problem:

    1. This program generates a table with really thick lines. There is no
    specific code that sets the table line thicknesses.
    2. I looked at the SW api help and see that there is a command
    TableAnnotation::GridLineWeight which I can set. SW does not provide a
    sample call that demonstrates how a) I should activate this table and
    b) how to modify the actual thickness (i.e. do I use normal, thick,
    thick2) or numbers?

    Request:

    Can someone supply me with several lines of code (example) that shows
    me how to actually call and set the table properties.

    Or point me to a reference site where applicable examples exist?

    Given enought time I think I could figure it out - however, larger
    fires (deadlines) are getting in my way of obtaining "quality" time.


    Len

    Thank you in advance
     
    Len K. Mar, Jul 30, 2004
    #1
  2. To get hold of TableAnnotation objects call BomFeature.GetTableAnnotations,
    which returns an array of TableAnnotation.

    TableAnnotation::GridLineWeight takes a long, that is a whole number.
    Experimentation suggests that valid numbers seem to be 0 to 7 inclusive.
    You could start with this macro that I hacked out from the "Export BOMs to
    XML Example (VB)" in the SolidWorks API help.

    =============================
    Option Explicit

    Sub ProcessBomFeature( _
    swBomFeat As SldWorks.BomFeature, _
    lineWeight As Long)

    Dim swFeat As SldWorks.Feature
    Dim vTableArr As Variant
    Dim vTable As Variant
    Dim swTable As SldWorks.TableAnnotation
    Set swFeat = swBomFeat.GetFeature

    vTableArr = swBomFeat.GetTableAnnotations

    For Each vTable In vTableArr

    Set swTable = vTable

    swTable.GridLineWeight = lineWeight
    Next vTable

    End Sub

    Sub main()

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swSheet As SldWorks.Sheet
    Dim swFeat As SldWorks.Feature
    Dim swBomFeat As SldWorks.BomFeature
    Dim nNumSheet As Long
    Dim nRetval As Long
    Dim i As Long
    Dim bRet As Boolean

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel

    Set swFeat = swModel.FirstFeature

    Do While Not swFeat Is Nothing

    If "BomFeat" = swFeat.GetTypeName Then

    Set swBomFeat = swFeat.GetSpecificFeature2
    ' lineWeight values
    ProcessBomFeature swBomFeat, 1

    End If
    Set swFeat = swFeat.GetNextFeature
    Loop
    End Sub

    =============================
    Paul Delhanty
    CADCAMbridge Ltd
    SolidWorks Research Partner
    http://www.cadcambridge.net
     
    Paul Delhanty, Jul 31, 2004
    #2
  3. Len K. Mar

    Len K. Mar Guest

    Paul,

    Thank you for the help.

    Len


     
    Len K. Mar, Aug 1, 2004
    #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.