10 Replies Latest reply on Nov 15, 2018 10:38 AM by Maciej Mazik

    Select face

    Maciej Mazik

      Hello

      I have problem with face selecting, I use this:

      model.Extension.SelectByID2("", "FACE", 1020 / 1000, 800 / 1000, 985 / 1000, True, 1, Nothing, 0)
      

      But this select wrong face. I try to find some resolution and I added line:

      model.CreateLine2(1020 / 1000, 400 / 1000, 985 / 1000, 1020 / 1000, 600 / 1000, 985 / 1000)
      

      This line is making on good face with the same parameters.

      Have you get any idea, what Im doing wrong?

        • Re: Select face
          William Cruz

          If you know what you are looking for, you can just traverse the component faces and then select. The code below is from the SW online with some minor modifications.

           

          public void SelectFace(Body2 swBody)
                  {
                      Face2 swFace = default(Face2);
                      Entity swEnt = default(Entity);
          
                      /*traverse all faces*/
                      swFace = (Face2)swBody.GetFirstFace();
                      while ((null != swFace))
                      {
                          swEnt = (Entity)swFace;
          
                          if (true /*select if this is the one*/)
                          {
                              swEnt.Select2(false, -1);
                              return;
                          }
                          else
                          {
                              swFace = (Face2)swFace.GetNextFace();
                          }
                      }
                  }
          
          • Re: Select face
            Maciej Mazik

            Bez tytułu.png

            I got point X,Y,Z on face. I' am trying to choose 2 surface on profil face. I tried method SelectByRay, its works for 1 side only.

              • Re: Select face
                Maciej Mazik
                Dim rayVecX = -1.0#
                Dim rayVecY = 0.0#
                Dim rayVecZ = 0.0#
                model.Extension.SelectByRay(1020 / 1000, 800 / 1000, 985 / 1000, rayVecX, rayVecY, rayVecZ, radius, swSelectType_e.swSelFACES, False, 0, swSelectOption_e.swSelectOptionDefault)
                

                Bez tytułu.png

                This code causes that right side of beam god selection. I try to select left side ( green line ).

                I try to do this with code, but it dont work.

                Dim rayVecX = 1.0#
                Dim rayVecY = 0.0#
                Dim rayVecZ = 0.0#
                model.Extension.SelectByRay(980 / 1000, 800 / 1000, 985 / 1000, rayVecX, rayVecY, rayVecZ, radius, swSelectType_e.swSelFACES, False, 0, swSelectOption_e.swSelectOptionDefault)
                

                 

                P.S. I still dont understand, why selectid2 dont work with me. I dont change a view of model.

                  • Re: Select face
                    William Cruz

                    SelectByRay only selects one by design, try using MultiSelectByRay

                      • Re: Select face
                        Maciej Mazik

                        i dont want select many face in one time by multiSelect. I just want select second face (green line) trying doing this with my code, but not work.

                          • Re: Select face
                            William Cruz

                            will it always be the second face or is it in a random index?

                              • Re: Select face
                                Maciej Mazik
                                Dim rayVecX = 1.0#  
                                Dim rayVecY = 1.0#  
                                Dim rayVecZ = 1.0#  
                                model.Extension.SelectByRay(980 / 1000, 800 / 1000, 985 / 1000, rayVecX, rayVecY, rayVecZ, radius, swSelectType_e.swSelFACES, False, 0, swSelectOption_e.swSelectOptionDefault)
                                
                                

                                When I change rayVecY to 1.0 and rayVecZ to 1.0 then my code will select correct face (blue line on image) .

                                Bez tytułu.png

                                Could you help me understand SelectByRay?

                                First three parameters are X,Y,Z of start point. next three parameters are direct of vector. So my vector and point is look like on image.

                                So I should write: (but this wasnt correct)

                                Dim rayVecX = 1.0#  
                                Dim rayVecY = 0.0#  
                                Dim rayVecZ = 0.0#  
                                
                                

                                Other combination of ray coordinates  cause that a face mark like a green line, was selected.

                      • Re: Select face
                        Maciej Mazik

                        I fix my problem. Added:

                               model.ShowNamedView2("Isometric", 7)
                                model.Extension.ViewZoomToSheet()
                        

                        and start using SelectID2.