3 Replies Latest reply on Jul 22, 2016 1:15 PM by Danny Bradford

    Solidworks API AddMate3 Concentricity will not create

    Danny Bradford

      Greetings all,

       

      I need to create a concentricity mate between a hole and an axis. Below is the code that selects and should create the Mate. The selections work, I can see that, however the mate will not create.

       

                  FirstSelection = "Axis3@" & Part.Name2 & "@" & AssemblyName

       

                  Full_feature_name = the_hole.Name & "@" & select_string

       

                  boolstat = swDocExt.SelectByID2(Full_feature_name, "BODYFEATURE", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

                  boolstat = swDocExt.SelectByID2(FirstSelection, "AXIS", 0, 0, 0, True, 1, Nothing, swSelectOption_e.swSelectOptionDefault)

       

                  matefeature(0) = swAssembly.AddMate3(swMateType_e.swMatePARALLEL, swMateAlign_e.swMateAlignCLOSEST, False, 0, 0, 0, 0, 0, 0, 0, 0, False, mateError)

       

      This code uses the same variables to create other mates so I am fairly sure they are good. Also, the mateError returns a 0.

       

      I am building this in VB.NET and we are running Solidworks 2015 SP02.

       

      Any help and direction is greatly appreciated.

       

      Thanks in advance for your time and attention.

        • Re: Solidworks API AddMate3 Concentricity will not create
          Simon Turner

          Your Full_feature_name seems to be selecting a Feature. Shouldn't it be selecting a cylindrical face? You can't add a mate to a Feature. You may need to find the list of faces defined by that feature and select the one which is a cylinder.

           

          Secondly, the mate you are trying to add is a Parallel mate. Use swMateType_e.swMateCOINCIDENT if you want a coincident mate.

           

          By the way, AddMate5 is the latest version of that command. You should use that instead of AddMate3.

            • Re: Solidworks API AddMate3 Concentricity will not create
              Danny Bradford

              Thanks for the input. You are right I was trying to make anything work so I switched to Parallel just as a check and forgot to switch it back for this post.

               

              Taking your advice I am trying to select the faces of the simple hole feature but having a devil of a time. Here is the code I have in an attempt to select the face but it does not select:

               

              holeface is a Face2

              the_hole is a Feature

              sel_entity is an Entity

               

                          holeface = the_hole.IGetFaces2(the_hole.GetFaceCount)

               

                          'Align pin and hole.

                          swModel.ClearSelection2(True)

               

                          sel_entity = holeface

               

                          boolstat = sel_entity.Select2(False, 1)

               

              I have tried to loop through all faces pulled from the Get Face line but there is only one returned and the iGetFaces2 does not return an array.

               

              Thanks for your help.

            • Re: Solidworks API AddMate3 Concentricity will not create
              Danny Bradford

              I am at a loss. There is no reason this is not working:

               

              holeface = the_hole.GetFaces(0)

               

                          holesurf = holeface.IGetSurface

               

                          MsgBox(holesurf.IsCylinder)

               

                          sel_entity = holeface

               

                          boolstat = sel_entity.Select2(False, 1)

                          MsgBox(boolstat)

               

              The first message box reports True which means I have the correct face in my grasp but the second message box reports False which means it did not select.

               

              Any help is GREATLY appreciated.