AnsweredAssumed Answered

Could not get the color from attched part with my macro ?

Question asked by Vincent Li on Jun 22, 2016
Latest reply on Jun 22, 2016 by Vincent Li

Hi Master Shi Fu,

 

I don't know why I could not get the color from the attched part with below code

(I had made a video to show my moves.)

Sub main()

Dim swapp                   As SldWorks.SldWorks

Dim swmodel                 As SldWorks.ModelDoc2

Dim swPrt                   As SldWorks.PartDoc

Dim swConfig                As SldWorks.Configuration

 

 

Dim configNames             As Variant

Dim swBodies()                As SldWorks.Body2

Dim swBody                  As SldWorks.Body2

Dim vBody                   As Variant

Dim vBodyArr                As Variant

 

 

Dim swFaces()               As Face2

Dim swFace                  As Face2

Dim vFace                   As Variant

Dim vProps                  As Variant

 

Set swapp = Application.SldWorks

Set swmodel = swapp.ActiveDoc

Set swPrt = swmodel

Set swConfig = swmodel.GetActiveConfiguration

 

Debug.Print swConfig.Name

swBodies = swPrt.GetBodies2(swAllBodies, True)

For Each vBody In swBodies

                                   

        Set swBody = vBody

       

        swFaces = swBody.GetFaces()

   

        For Each vFace In swFaces

       

            Set swFace = vFace

                selFace = swFace.Select(True)

                vProps = swFace.GetMaterialPropertyValues2(swThisConfiguration, swConfig.Name)

                Debug.Print Val(vProps(0)); "//" & Val(vProps(1)) & "//" & Val(vProps(2))

        Next

    Next

 

End Sub

Outcomes