4 Replies Latest reply on Jun 5, 2017 4:09 PM by Dave Paul

    Get a part feature name associated to an assembly mate

    Dave Paul

      I'm looking for a way to print a file of the hardware mates within an assembly.  We have run into situations where there is a 10-32 tap with an M5 screw mated to the tap.  I'm working on a way to traverse the mates and print a list of components and the component features that they are mated to in the assembly.

      I found an VBA example that traverses all the mates in the assembly, but I need it to go one step farther.

      I need the feature name where the component is mated.  Is this possible?

       

      For instance:

          Concentric9

            Type         = 1

            AlignFlag    = 1

            CanBeFlipped = False

            Component    = A - Flange1-1

            MateEntType  = 4

            Feature Name = #10-32 Tapped Hole1

       

          Concentric9

            Type         = 1

            AlignFlag    = 1

            CanBeFlipped = False

            Component    = HX-SHCS, 10-32 (ALL LENGTHS)-1

            MateEntType  = 4

            Feature Name = Base-Revolve

        • Re: Get a part feature name associated to an assembly mate
          Josh Brady

          Dave,

          How bulletproof do you need this macro to be?  I ask because there are quite a number of ways to mate a hardware component in an assembly. 

          In SolidWorks, faces are "owned" by features.  However, a face may be "owned" by more than one feature.  The API can tell you the feature highest in the tree that "owns" that face.  I believe that will be the same feature that the UI highlights when you select the face.  As long as your concentric mate is using that face, it's probably that feature.

           

          However, if the screw is concentric-mated to the edge of a hole, the mate entity is that edge.  Edges are not "owned" by features. They're more like the boundary between two faces, which are probably owned by different features.  You would need to check both faces returned by Edge::GetTwoAdjacentFaces2 to see which one of them is cylindrical.  That face probably is owned by the feature you're interested in.

           

          The concentric mate could also be to a sketchpoint in the sketch defining the hole locations.  Some people like to create a sketch full of sketchpoints, then create their hole wizard on top of that sketch.  In that case, one could mate to the defining sketch, which isn't related to your feature of interest at all.

           

          Also, isn't it unusual to mate a fastener to a tapped hole?  Wouldn't the fastener be more likely mated to a clearance hole in the part that's being fastened down?