4 Replies Latest reply on Jun 20, 2018 5:54 AM by Paul Kerouanton

    Extract the mates data in excel

    Paul Kerouanton

      Hello everybody,

       

      I need you. I try to extract the mates' data in excel. For the moment I can extract the names of the part and for each part, I can extract the mates' data. But when I extract the mates' data in my Excel is not very readable because all data are extracted but we can't see with which part.

      Like this :

       

      Capture.JPGNow I try to display for each mate with which piece it is in mates. Like this:Capture2.JPG

      I join you my macro if you have any idea do not hesitate to contact me.

        • Re: Extract the mates data in excel
          Fifi Riri

          Could you give a screenshot of what you would want for the cells arrangement and content.

           

          Also: Does your assembly has sub-assemblies?

            • Re: Extract the mates data in excel
              Paul Kerouanton

              Hello Fifi Riri

              Thank you for your answer. Ok, I will try to explain you, what I want to do. On the first line, you can see the name of part of my assembly. And for each part, the macro extract all the mates (all line after the line 2), but for the moment we can't see with which part the part of cells one is in the constraint. I try to extract the name of mates and the name of the part with which the part of the first cells is in mates. tableau.JPG

              My assembly does not have sub-assemblies.

                • Re: Extract the mates data in excel
                  Fifi Riri

                  Ok. A quick fix would be to replace your "Select Case" with this:

                   

                                      Dim swComp As SldWorks.Component2

                                      Set swComp = SingleMate.MateEntity(0).ReferenceComponent

                                      If swComponent.Name2 = swComp.Name2 Then

                                          Set swComp = SingleMate.MateEntity(1).ReferenceComponent

                                      End If

                                      Dim MyComp As String

                                      MyComp = swComp.Name2

                                      'Debug.Print "Name of component: " & MyComp

                   

                                      Dim MyMate As String

                                      Select Case typeOfMate

                                          Case 0

                                              MyMate = "Coincident"

                                          Case 1

                                              MyMate = "Concentric"

                                          Case 2

                                              MyMate = "Perpendicular"

                                          Case 3

                                              MyMate = "Parallel"

                                          Case 4

                                              MyMate = "Tangent"

                                          Case 5

                                              MyMate = "Distance"

                                          Case 6

                                              MyMate = "Angle"

                                          Case 7

                                              MyMate = "Unknown"

                                          Case 8

                                              MyMate = "Symmetric"

                                          Case Else

                                              MyMate = "Other"

                                      End Select

                                      Debug.Print MyMate & " - " & MyComp

                                      xlWs.cells(x, y).Value = MyMate & " - " & MyComp

                   

                  You can also look into: http://help.solidworks.com/2015/english/api/sldworksapi/get_mates_and_mate_entities_example_vb.htm