3 Replies Latest reply on Jun 4, 2014 10:09 AM by Simon Turner

    how to select an edge

    Vijay Kumar

      How to select an edge of a circle with it's centre point coordinate system.

       

      I have to create the bolt connector for a rectangular flange having n-number of holes through API.

      I am having the coordinates of all the circles in that flange.I need to create the bolt connector.

       

      while selecting an edge of a circle using coordinates the front edge (facing the current view say edge-1) is selected,

      but the behind edge (directly opposite to the selected one say edge-2) is not selected.

       

      Instead of selecting the edge-2 it will select the nearby any other edges (say straight or curved one) or none.

       

      It will select the edge-2, only when the model is get rotated  that is (facing the rear view)

       

      It is too difficult to rotate the model for facing the edge to be selected.

       

      Could you please anybody give me the solution for without rotating the model the both edges should be selected using the coordinates.

       

      ******************the model code  start**************************

       

       

                      swModel.ShowNamedView2 "*Isometric", 7

                      swModel.ViewZoomTo2 Carraypt(i, 0), Carraypt(i, 1), Carraypt(i, 2), Carraypt2(j, 0), Carraypt2(j, 1), Carraypt2(j, 2)

       

                      boolstatus = swModel.Extension.SelectByID2("", "EDGE", Carraypt(i, 0), Carraypt(i, 1), Carraypt(i, 2), True, 0, Nothing, 0)

       

                     Set myModelView = swModel.ActiveView

                     myModelView.RotateAboutPoint 3.14, 0, Carraypt2(j, 0), Carraypt2(j, 1), Carraypt2(j, 2)

       

                     boolstatus = swModel.Extension.SelectByID2("", "EDGE", Carraypt2(j, 0), Carraypt2(j, 1), Carraypt2(j, 2), True, 0, Nothing, 0)

       

                      swModel.ShowNamedView2 "*Isometric", 7

                      swModel.ViewZoomtofit2

       

                      boltconnectormain -(it is a function for creating the bolt connector)

       

                      swModel.ClearSelection2 True 

       

       

      ******************the model code   end**************************

        • Re: how to select an edge
          Simon Turner

          I would get the all edges of the body (Body2.GetEdges) and then loop through all of them until you find one which is a circle and whose circle parameters (centre point and radius) match your CarrayPt2.

          So, assuming your swModel is a PartDoc:

           

          dim myPart as PartDoc

          Dim bodyArray as Variant

          Dim myBody as Body2

          Dim edgeArray as Variant

          Dim i as Integer

          Dim myCurve as Curve

          Dim myEdge as Edge

          Dim myParams as Variant

          Dim myEnt as Entity

           

          Set myPart = swModel

          bodyArray = myPart.GetBodies2(swSolidBody, True)

          Set myBody = bodyArray(0) 'I'm assuming you just have one solid body. Otherwise loop through all of bodyArray

          edgeArray = myBody.GetEdges

          For i = 0 To Ubound(edgeArray)

               Set myEdge = edgeAray(i)

               Set myCurve = myEdge.GetCurve

               If myCurve.IsCircle Then

                    myParams = myCurve.CircleParams

                    if Abs(myParams(0) - CarrayPt(0)) < 0.0001 And Abs(myParams(1) - CarrayPt(1)) < 0.0001 And Abs(myParams(2) - CarrayPt(2)) < 0.0001 And Abs(myParams(6) - theRadius) < 0.0001 Then

                         Set myEnt = myEdge

                         myEnt.Select4, False, Nothing

                             boltconnectormain

                              exit for

                    end if

                   end if

          next

           

           

           

          All untested code - just wrote if from the top of my head

            • Re: how to select an edge
              Vijay Kumar

              Hi, Simon,

               

              Thanks for your reply.

               

              In my code I already get the arrays (carraypt(), carraypt2())  by means of the same procedure what you are telling.

               

              But i have a difficulty that i need to select the two circular edges at a time, whose having the coordinates of same values in two directions (X direction,Y direction. it may vary on Z direction).

               

              I have two arrays namely carraypt(), carraypt2(). in this array i had the centre point coordiates of circular edges of two faces

               

              (for a Flange) are stored

               

              like:-

              help1.JPG

               

               

               

               

              help2.JPG

              carraypt(0)=0.02:carraypt(1)=0.01:carraypt(2)=0.03:

               

              carraypt2(0)=0.02:carraypt2(1)=0.01:carraypt(2)=0.04:

               

               

              For a boltconnector creation (through API) we need to select the two edges of a same hole correct.

               

              I need to do this for the above attached image.Kindly do the same.

               

              Now, give me a solution to select the both edges for creating a boltconnector.

               

              Regards,

               

              vkm.