Listing holes in a face of folded metal VB

Top  Previous  Next

This code was the starting point for this.

 

 

  // Set a reference to the sheet metal document.

  // This assumes a part document is active.

  Dim oPartDoc As PartDocument

  Set oPartDoc = ThisApplication.ActiveDocument

 

  // Make sure the document is a sheet metal document.

  if (oPartDoc.SubType == "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}")

       {

      MessageBox.Show ("A sheet metal document must be open.")

      return

  }

 

  // Get the sheet metal component definition.  Because this is a part document whose

  // sub type is sheet metal, the document will return a SheetMetalComponentDefinition

  // instead of a PartComponentDefinition.

  Dim oSheetMetalCompDef As SheetMetalComponentDefinition

  Set oSheetMetalCompDef = oPartDoc.ComponentDefinition

 

  // Iterate through the features looking specifically for sheet metal features.

  Dim oFeature As PartFeature

  For Each oFeature In oSheetMetalCompDef.Features

      switch (oFeature.Type) {

          Case kFaceFeatureObject

              Dim oFaceFeature As FaceFeature

              Set oFaceFeature = oFeature

              Debug.WriteLine ( "Face Feature: " + oFaceFeature.Name) ;

              Debug.WriteLine ( "   Adaptive: " + oFaceFeature.Adaptive) ;

              Debug.WriteLine ( "   Face Count: " + oFaceFeature.Faces.Count) ;

              Debug.WriteLine ( "   HealthStatus: " + oFaceFeature.HealthStatus) ;

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")" ) ;

              Debug.WriteLine ( "   Suppressed: " + oFaceFeature.Suppressed ;

                               break ;

                               

          Case kContourFlangeFeatureObject

              Dim oContourFlangeFeature As ContourFlangeFeature

              Set oContourFlangeFeature = oFeature

              Debug.WriteLine ( "Contour Flange Feature: " + oContourFlangeFeature.Name) ;

              Debug.WriteLine ( "   Adaptive: " + oContourFlangeFeature.Adaptive) ;

              Debug.WriteLine ( "   Face Count: " + oContourFlangeFeature.Faces.Count) ;

              Debug.WriteLine ( "   HealthStatus: " + oContourFlangeFeature.HealthStatus) ;

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")") ;

              Debug.WriteLine ( "   Suppressed: " + oContourFlangeFeature.Suppressed ;

                               break ;

                               

          Case kCutFeatureObject

              Dim oCutFeature As CutFeature

              Set oCutFeature = oFeature

              Debug.WriteLine ( "Cut Feature: " + oCutFeature.Name) ;

              Debug.WriteLine ( "   Adaptive: " + oCutFeature.Adaptive) ;

              Debug.WriteLine ( "   Face Count: " + oCutFeature.Faces.Count) ;

              Debug.WriteLine ( "   HealthStatus: " + oCutFeature.HealthStatus) ;

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")") ;

              Debug.WriteLine ( "   Suppressed: " + oCutFeature.Suppressed

                               break ;

                               

          Case kFlangeFeatureObject

              Dim oFlangeFeature As FlangeFeature

              Set oFlangeFeature = oFeature

              Debug.WriteLine ( "Flange Feature: " + oFlangeFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oFlangeFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oFlangeFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oFlangeFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oFlangeFeature.Suppressed

                               break ;

                               

          Case kHemFeatureObject

              Dim oHemFeature As HemFeature

              Set oHemFeature = oFeature

              Debug.WriteLine ( "Hem Feature: " + oHemFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oHemFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oHemFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oHemFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oHemFeature.Suppressed

                               break ;

                               

          Case kFoldFeatureObject

              Dim oFoldFeature As FoldFeature

              Set oFoldFeature = oFeature

              Debug.WriteLine ( "Fold Feature: " + oFoldFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oFoldFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oFoldFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oFoldFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oFoldFeature.Suppressed

                               break ;

                               

          Case kCornerFeatureObject

              Dim oCornerFeature As CornerFeature

              Set oCornerFeature = oFeature

              Debug.WriteLine ( "Corner Seam Feature: " + oCornerFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oCornerFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oCornerFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oCornerFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oCornerFeature.Suppressed

                               break ;

                               

          Case kBendFeatureObject

              Dim oBendFeature As BendFeature

              Set oBendFeature = oFeature

              Debug.WriteLine ( "Bend Feature: " + oBendFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oBendFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oBendFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oBendFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oBendFeature.Suppressed

                               break ;

                               

          Case kCornerRoundFeatureObject

              Dim oCornerRoundFeature As CornerRoundFeature

              Set oCornerRoundFeature = oFeature

              Debug.WriteLine ( "Corner Round Feature: " + oCornerRoundFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oCornerRoundFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oCornerRoundFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oCornerRoundFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oCornerRoundFeature.Suppressed

                               break ;

                               

          Case kCornerChamferFeatureObject

              Dim oCornerChamferFeature As CornerChamferFeature

              Set oCornerChamferFeature = oFeature

              Debug.WriteLine ( "Corner Chamfer Feature: " + oCornerChamferFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oCornerChamferFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oCornerChamferFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oCornerChamferFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oCornerChamferFeature.Suppressed

                               break ;

                               

          Case kPunchToolFeatureObject

              Dim oPunchToolFeature As PunchToolFeature

              Set oPunchToolFeature = oFeature

              Debug.WriteLine ( "Punch Tool Feature: " + oPunchToolFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oPunchToolFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oPunchToolFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oPunchToolFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oPunchToolFeature.Suppressed

                               break ;

                               

          Case Else

              Debug.WriteLine ( "Non Sheetmetal Feature: " + oFeature.Name

              Debug.WriteLine ( "   Adaptive: " + oFeature.Adaptive

              Debug.WriteLine ( "   Face Count: " + oFeature.Faces.Count

              Debug.WriteLine ( "   HealthStatus: " + oFeature.HealthStatus

              Debug.WriteLine ( "   RangeBox: (" + Format(oFaceFeature.RangeBox.MinPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MinPoint.Z, "0.00000") + ")-(" +

                                      Format(oFaceFeature.RangeBox.MaxPoint.X, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Y, "0.00000") + ", " +

                                      Format(oFaceFeature.RangeBox.MaxPoint.Z, "0.00000") + ")"

              Debug.WriteLine ( "   Suppressed: " + oFeature.Suppressed

                               break ;

                               

      }

  Next

End Sub

 

 

 

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)