AnsweredAssumed Answered

How to choose a face to mate distance in an assembly?

Question asked by Shi Xiaochen on Apr 17, 2018
Latest reply on Apr 19, 2018 by Ivana Kolin

I am doing a project, the project’s function is that operators input some parameters and then it will produce parts and mate these parts automatically. The assembly relationship is to choose plane of two parts and then set distance mate, just like the pictures below show:

 

111.png

 

Now I have some troubles...

1. How to get the specific planes and mate them? I have tried the SelectionMgr, but when debugging I click the parts and it doesn't react, it seems that after I stop debugging can those parts be chosen.

2. I use AddMate5 but it just doesn't work , here are part of my codes:

 

 

 

            tmpObj = (ModelDoc2)swApp.OpenDoc6(ADDRESS + "part"+i+".SLDPRT", (int)

            swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);

 

            strCompModelname = "part" + i + ".sldprt";

            swDoc = (ModelDoc2)swApp.ActivateDoc3("gb_assembly.asmdot", true, (int)swRebuildOnActivation_e.swUserDecision, ref errors);

 

              swComponent = (Component2)swAssemblyDoc.AddComponent5(

              strCompModelname, (int)

              swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig,

              "", false, "", -1, -1, -1);

          

            strCompName = swComponent.Name2;

       

            FirstSelection = "FrontPlane@" + strCompName0 + "@" + AssemblyName;

            SecondSelection = "FrontPlane@" + strCompName + "@" + AssemblyName;

 

            swDoc.ClearSelection2(true);

            swDocExt = (ModelDocExtension)swDoc.Extension;

          

            boolstat = swDocExt.SelectByID2(FirstSelection, "PLANE", 0, 0, 0, true, 1, null, (int)

                swSelectOption_e.swSelectOptionDefault);

            boolstat = swDocExt.SelectByID2(SecondSelection, "PLANE", 0, 0, 0, true, 1, null, (int)

            swSelectOption_e.swSelectOptionDefault);

           

            matefeature = (Feature)swAssemblyDoc.AddMate5((int)swMateType_e.swMateDISTANCE, (int)

                swMateAlign_e.swMateAlignALIGNED, true, 0.020, 0.145, 0.012, 0.001, 0.001,

                0, 0, 0, false, false, 0, out mateError);

             swDoc.ClearSelection2(true);

 

How to select specific faces and mate them? I do need help!

 

Shi

Outcomes