4 Replies Latest reply on Jul 1, 2015 8:28 AM by Dave Paul

    Get all holes attached to a hole callout dimension

    Dave Paul

      I need to loop thru all the holes that are attached to a hole callout dimension.  When I get the annotations of the hole callout dimension that is attached to four holes, all holes seem to be one feature.  I need to dig one level deeper and get the individual holes.  All I need is an array of the holes.

       

      Here is what I have:

       

         Set swDimension = swSelMgr.GetSelectedObject5(1)
          Select Case swSelMgr.GetSelectedObjectType2(1)
            Case swSelectType_e.swSelDIMENSIONS:
              Debug.Print "Dimension"
              If swDimension.IsHoleCallout Then
                Debug.Print "--> Hole Callout"
                Set swAnnotation = swDimension.GetAnnotation
                Call DisplayDimensionText(swAnnotation, swDimension)
                swEnts = swAnnotation.GetAttachedEntities
                Set swEnts = swEnts.GetAnnotation  <==  I think I need to get the annotations of an annotation to get the individual holes
                vAttEntTypeArr = swAnnotation.GetAttachedEntityTypes
              End If
           End Select
      

       

      All thoughts and ideas are appreciated - Dave

        • Re: Get all holes attached to a hole callout dimension
          Simon Turner

          First of all, you should use GetAttachedEntities3, which has been available since 2008 and will be more reliable.

          The swEnts, if it is not empty, will be an array of entities, so you will need to loop through the array.

          Here is some pseudo that I haven't tested:

           

               Dim i As Integer

               Dim thisEnt as Entity

           

               swEnts = swAnnotation.GetAttachedEntities

               vAttEntTypeArr = swAnnotation.GetAttachedEntityTypes2

           

               If swEnts IsNot Nothing Then 'This is .Net code. If you are using VBA then you need to write If IsEmpty(swEnts)=False Then

                    For i = 0 To UBound(swEnts)

                         Debug.Print "Type of attached entity(" & i + 1 & ") as defined in swSelectType_e  = " & vAttEntTypeArr(i)

           

                         Set thisEnt = swEnts(i) 

                    Next

               End If

            • Re: Get all holes attached to a hole callout dimension
              Dave Paul

              Simon,

              Thank you for your response.

              If I select the "10-32" callout and run the code, the swEnts array only has one element.  Now if I select that single element in the array with the code:

               

              Set swEdge = swEnt
              vFace = swEdge.GetTwoAdjacentFaces2()
              Set swFace = vFace(0)
              swFace.GetFeature.Select2 False, 0
              

               

              it selects all four holes at once.

               

              I would like to have access to each of the four individual holes.

               

              Dave

                • Re: Get all holes attached to a hole callout dimension
                  Simon Turner

                  There's quite a lot to say here:

                  1. The annotation is really only attached to 1 entity

                  2. That entity in this case is an Edge - hopefully you checked the entity type before setting seEdge = swEnt?

                  3. The edge belongs to 2 faces and you just process the first one, rather than checking to see if it is planar or cylindrical. You might need to use the second face.

                  4. You have successfully retrieved a cylindrical (by chance!), but then step back and select the feature which defines all 4 holes

                  5. But that's OK, because you can now call GetFaces on the feature to retrieve the list of 4 faces that you wanted in the first place. Again, it might return the planar face that the holes are drilled into, so loop through all of them and only select the cylindrical ones.

                   

                  Hope that helps.