API - how to get Thickness

Discussion in 'SolidWorks' started by John, Sep 30, 2003.

  1. John

    John Guest

    In VBA I have:

    Dim Model As ModelDoc2

    and I try to access the sheet metal thickness like this:

    Model.feature.SheetMetalFeatureData.thickness

    .... but apparently that is not how to get it. What is the statement that
    retrieves the thickness?

    John
     
    John, Sep 30, 2003
    #1
  2. John

    John Guest

    Can you be specific and show an example?
    My major trouble seem to be to get it exactly right - in terms of defining
    the variables etc - so an example would be nice.
    John
     
    John, Sep 30, 2003
    #2
  3. this is not tested but it should work. if it does not work then it
    will at least give you the idea of how it is done.

    sub main()

    dim swapp as sldworks.sldworks
    dim model as modeldoc2
    dim firstfeature as feature
    dim nextfeature as feature
    dim FeatureDefinition as SheetMetalFeatureData
    dim thickness as double

    set swapp = new sldworks.sldworks

    set model = swapp.activedoc

    set firstfeature = model.firstfeature

    set nextfeature = firstfeature.getnextfeature

    while nextfeature.gettypename <> "SheetMetal"

    set firstfeature = nextfeature.getnextfeature

    set nextfeature = firstfeature

    loop

    set FeatureDefinition = nextfeature.GetDefinition

    thickness = FeatureDefinition.Thickness

    debug.print thickness

    end sub
     
    Sean Phillips, Sep 30, 2003
    #3
  4. sorry i forgot the "DO"

    sub main()

    dim swapp as sldworks.sldworks
    dim model as modeldoc2
    dim firstfeature as feature
    dim nextfeature as feature
    dim FeatureDefinition as SheetMetalFeatureData
    dim thickness as double

    set swapp = new sldworks.sldworks

    set model = swapp.activedoc

    set firstfeature = model.firstfeature

    set nextfeature = firstfeature.getnextfeature

    do while nextfeature.gettypename <> "SheetMetal"

    set firstfeature = nextfeature.getnextfeature

    set nextfeature = firstfeature

    loop

    set FeatureDefinition = nextfeature.GetDefinition

    thickness = FeatureDefinition.Thickness

    debug.print thickness

    end sub
     
    Sean Phillips, Oct 1, 2003
    #4
  5. Hi all...

    Regarding the "thickness" problem. I used this code in one of my utilities...

    swType = swFeature.GetTypeName()
    If (swType = "Shell") Then
    smThk = swFeature.GetDefinition.Thickness()
    ElseIf (swType = "SheetMetal") Then
    smThk = swFeature.GetDefinition.Thickness()

    etc...

    Remember that while traversing the feature tree, you have to keep track of
    where ("shell" or "sheetmetal") you got a valid thickness value.

    Regards,

    Vinodh Kumar M
     
    Vinodh Kumar M, Oct 1, 2003
    #5
  6. John

    John Guest

    Is there no way of adressing a feature directly? (Instead of having to loop
    till yo find it...)
    John
     
    John, Oct 1, 2003
    #6
  7. featurebyname

     
    Sean Phillips, Oct 2, 2003
    #7
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.