AnsweredAssumed Answered

Get mate faces

Question asked by Lyao Myao on Oct 13, 2014
Latest reply on Oct 15, 2014 by Lyao Myao

Hello! I want to automate smart feature insertion by extracting faces for smart feature from mates data.

 

I have part "box" (smart component) with face "box_face"  and part "block".

They are mated coincident by box_face<->block_someFace.

I want to run macro, to find face that mated with box_face and later apply smart feature to that face.

 

Pseudo code:

Dim targetFace as Face

for i=1 to box.mates.count

     mateInfo=box.mates(i)

     if (mateInfo.face(1)='box_face') then 'if first face is our marker face

          targetFace=mateInfo.face(2); 'then we found it, store second face

     end if

next i

 

box.insertSmartFeature(targetFace)

 

---------------------

Now i m stuck at getting the face info from mates.

 

... got all smart part mates  in Mates array

For Each SingleMate In Mates

      Dim swMate As SldWorks.Mate2

      Dim typeOfMate As Long

      If TypeOf SingleMate Is SldWorks.Mate2 Then

            Set swMate = SingleMate

             typeOfMate = swMate.Type

 

             If typeOfMate = 0 Then

                        Debug.Print "Mate type: Coincident"

                        Dim mateEntityCount As Integer

                

                        Dim meI As Integer

                        Dim ents As SldWorks.MateEntity2

                        Dim zzzz As Variant

                        Dim zzzz2 As Variant

                        mateEntityCount = swMate.GetMateEntityCount

                       

                        For meI = 0 To count - 1

                            Set ents= swMate.MateEntity(meI)

                            Set zzzz = ents.ReferenceComponent

                            Set zzzz2 = ents.Reference

                              'zzzz and zzzz2 will contain Component, not Face. How can i get faces for current swMate??

                       Next meI

                 End If

          End If

Next

 

 

 

 

Thanks!

Outcomes