6 Replies Latest reply on Aug 8, 2017 11:37 PM by Jacob Corder

    hole diameter

    Nadav Gover

      Hi,

      is there a way of getting all hole diameters?

      in fact, not only circular holes but any polygon?

       

      I found this:

      2017 SOLIDWORKS API Help - Select Edges of All Holes on Face Example (C#)

      2017 SOLIDWORKS API Help - Select Loop of Edges Example (VBA)

      but none of them get the diameter/length of a hole.

       

      Any ideas?

      getting the type of the hole (circular or not) can also be helpful.

       

      Thanks

        • Re: hole diameter
          Peter Brinkhuis

          What are you trying to achieve? Maybe there's another way to get there.

            • Re: hole diameter
              Nadav Gover

              Trying to get the minimum aperture (opening\hole) in a part and it's type.

              To begin with, only the minimum aperture, its type is a bonus but maybe it easy to access.

                • Re: hole diameter
                  Peter Brinkhuis

                  Is it a complex part or a flat sheet? If it is a flat part, you might be able to create a sketch on the top surface, convert the whole surface to that sketch and then for example use IsCircle (ISketchArc) to find hole and their dimensions.

                   

                  If it is a complex part, I don't have the foggiest idea on where to start.

                  • Re: hole diameter
                    Nilesh Patel

                    Hi Nadav,

                     

                    Peter Brinkhuis has already mentioned one of the approach. Another approach I can think of is to run a loop through feature tree and find if the feature is a extrude cut, hole wizard or revolve cut and then get display dimensions. Check each dimensions and find the radial dimension. It depends on how you have dimensioned the sketch e.g. if you have dimensioned the edges in polygon rather than circle then you wont find any radial dimension.

                     

                    You just have to trial and error few approaches to find the solution you want.

                     

                    Regards,

                • Re: hole diameter
                  Jacob Corder

                  I would start with partdoc.getbodies

                   

                  Loop the bodies to get the faces.

                  Body.getfaces

                   

                  Loop the faces for cylinders

                  Face.getsurface

                  Surface.iscylinder

                  If yes. You found one.

                  Add that to a generic.list(of face2)

                   

                  At the end evaluate all of the cylinders for your needs

                  If you need to have only ones that intersect a face.

                   

                  Call face2.getEdges

                  Loop the edges and call

                  Edge.gettwoadjacentfaces

                  Get the face that is not the one used to get the edge.

                  Check if that face is the face you want to see if holes exist on.

                   

                  Alternatively you could get the face you want to know if holes exist on and use

                  face2.getedges.

                  Loop through the edges to find the next face same as above if that face is a cylinder, you found a hole.

                   

                  Do not check if the edge between the desired face, and the hole is a circle. Sometimes it evaluates as a spline.

                    • Re: hole diameter
                      Jacob Corder

                      To get the diameter. That is a value in isurface.cylinderparams(6) which is a radius.

                      To get the length. This is a bit tricky. You can possibly rely on uvbounds, but Its not totally reliable. If there are cross holes or blended surfaces, this gets hard. If they are straight holes, just measure the distance between each combination of each edge. I will try to add some code tomorrow when I get into work.