VBA: GetMaterialPropertyValues2?

Discussion in 'SolidWorks' started by Corey Scheich, May 25, 2004.

  1. I am trying to use the following code to get and set the material property
    values (I haven't gotten to the set part yet.) anyway
    GetMaterialPropertyValues2 returns an (8,1) array of doubles but they are
    all -1 instead of the settings of the feature in question. I have tried a
    few different scenerios but nothing is looking quit right. I also checked
    the example in the help file and couldn't see any significant difference.


    Dim swApp As Object
    Dim Part As SldWorks.ModelDoc2
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Feature
    Dim Component As Component2
    Dim V As Variant
    Dim Configs As Variant
    Dim SelMan As SldWorks.SelectionMgr
    Dim CompDoc As SldWorks.PartDoc

    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMan = Part.SelectionManager

    Part.ClearSelection2 True

    boolstatus = Part.Extension.SelectByID("Base-Revolve-Thin@140004-1@400988",
    "BODYFEATURE", 0, 0, 0, False, 0, Nothing)
    Set Feature = SelMan.GetSelectedObject5(1)
    Set Component = SelMan.GetSelectedObjectsComponent2(1)
    Set CompDoc = Component.GetModelDoc
    Configs = Part.GetConfigurationNames
    V = Feature.GetMaterialPropertyValues2(swSpecifyConfiguration, (Configs))
    Debug.Print V(1)
    Debug.Print V(2)
    Debug.Print V(3)
    Debug.Print V(4)
    Debug.Print V(5)
    Debug.Print V(6)
    Debug.Print V(7)
    Debug.Print V(8)
    Debug.Print Feature.Name
    Debug.Print "......................."
    End

    Any help would be appreciated

    Corey Scheich
     
    Corey Scheich, May 25, 2004
    #1
  2. Corey Scheich

    david peer Guest

    hi Corey

    I think the problem is the way you assign color to the feature.
    Make sure when you do, that "This configuration" is selected in the
    configuration group ,in the feature manager.
    the default is "All configurations" and somehow that gives the -1
    result.

    regards
    dudi peer
     
    david peer, May 26, 2004
    #2
  3. That is dumb. Yet somehow it is completely correct. Thank you very
    much!!!! Just when you think they would have it right you find out they
    forgot something.

    Corey
     
    Corey Scheich, May 26, 2004
    #3
  4. Corey Scheich

    kellnerp Guest

    I have been looking into that recently. First of all there is a priority in
    how SW sets material properties aka colors. For each face mps (material
    properties) can be set by the default color, body color, assembly color,
    feature color and finally face color. If a face color is set it overrides
    the others, then feature, and so on. So when you look at faces in a part
    they will all be set to -1 if they are the default, body, assembly, or
    feature color. To even find out what determines the color of a given face
    you have to look at all these things.

    There is an example of code in the API help and also a couple macros on the
    Trimech website concerning this problem.
     
    kellnerp, May 30, 2004
    #4
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.