9 Replies Latest reply on Jun 12, 2018 10:40 AM by Fariz Afzal

    Mate API not working

    Fariz Afzal

      HI all,

      I have an API which creates an assembly. It opens different parts and put them in the assembly and creates some mates. But once I run it few mates are suppressed after they are created. Any idea how I can fix it ? It is happening to some mates not all, and I am using the same command for all of them.

      Thanks in advance

      Fariz

        • Re: Mate API not working
          Josh Brady

          Some things that might help us answer your question:

           

          1. Is it repeatable?  If you run the macro twice on the same assembly, do the same mates get suppressed?

          2. Can you post an example assembly with your code?  Ideally, one that consistently demonstrates your issue with the least amount of extraneous code possible.

            • Re: Mate API not working
              Fariz Afzal

              Thanks for your reply. No it is not repeatable, it is happening to different mates every time. The code is too big to post here, but the code section I am using for mates are this :

              for co-incident :

              swAssy.ClearSelection2 (True)

              boolstatus = swAssy.Extension.SelectByID2(PL_tongue_plank_storage(i), "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)

              boolstatus = swAssy.Extension.SelectByID2(PL_groove_plank_storage(i + 1), "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)

              Set matefeature = swAssy.AddMate5(swMateCOINCIDENT, swMateAlignANTI_ALIGNED, False, 0, 0, 0, 0, 0, 0, 0, 0, False, False, 0, mateError)

               

              for distance :

               

              swAssy.ClearSelection2 (True)

              boolstatus = swAssy.Extension.SelectByID2(PL_middle_weldment, "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)

              boolstatus = swAssy.Extension.SelectByID2(PL_97_assy, "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)

              Set matefeature = swAssy.AddMate5(swMateType_e.swMateDISTANCE, swMateAlignANTI_ALIGNED, False, middle_to_BV_97, middle_to_BV_97, middle_to_BV_97, 0, 0, 0, 0, 0, False, False, 0, mateError)

               

              every mate I am using are basically copy of these two with some variations like aligned/anti aligned, dimensions flipped etc

              below screen shot shows the mates supressed

              Thanks

              Fariz

                • Re: Mate API not working
                  Josh Brady

                  Sorry, perhaps I should have been more clear...

                   

                  I'm not gonna write a bunch of code and make a bunch of test assemblies just to hope I recreate the same bug that you did. 

                   

                  There's a decent chance that while you are trying to simplify your code enough to isolate and post, you may find the problem yourself...

                  • Re: Mate API not working
                    Christopher Elyassi

                    Hey Fariz,

                     

                    There isn't enough info here to properly diagnose what's going on, but see below a few questions/suggestions:

                    -     Are you working with configurations in the assembly?

                    -     Are the mates always inserted in the same order?

                    -     Do you get errors in the assembly if you unsuppress the mates?

                    -     Can you try unsuppressing the mates programmatically?

                    -     If you know where the components need to be (X,Y,Z coords of the origin) can you just insert them in the assembly at the right position and leave them floating?

                      • Re: Mate API not working
                        Fariz Afzal

                        Christopher,

                        Answer to your questions

                         

                        There isn't enough info here to properly diagnose what's going on, but see below a few questions/suggestions:

                        -     Are you working with configurations in the assembly? No. But the part files I am using have configurations.

                        -     Are the mates always inserted in the same order? Yes

                        -     Do you get errors in the assembly if you unsuppress the mates? No

                        -     Can you try unsuppressing the mates programmatically? kind of. I found another code which can do it but that sub routine does not work if I call it from my main code.

                        -     If you know where the components need to be (X,Y,Z coords of the origin) can you just insert them in the assembly at the right position and leave them floating? This would not work in this case because my assembly changes based on some inputs so the part's positions change as well.

                         

                        Fariz

                      • Re: Mate API not working
                        Ivana Kolin

                        what is the difference between distance1 and distance4 mate (2 and 4, 3 and 5, 15 and 16)?

                        But without your model and whole macro is it not easy to guess what could be wrong.

                    • Re: Mate API not working
                      Fariz Afzal

                      All,

                      I could not figure out what was wrong but I found another api to unsuppress all th e mates.

                       

                      fariz