How to Extract Countersink/Counterbore Values -- Values Coming Out Null

How to Extract Countersink/Counterbore Values -- Values Coming Out Null

Anonymous
Not applicable
561 Views
2 Replies
Message 1 of 3

How to Extract Countersink/Counterbore Values -- Values Coming Out Null

Anonymous
Not applicable

Hello, 

 

I am using Inventor 2021. I am trying to detect and capture values from Counterbore/Countersink hole objects.

Does anyone know where these values are stored? I am looking within the HoleFeature object, which contains 

CSinkDiameter, CBoreDiameter, etc. 

These values are always returning null...anyone know why this is? I have attached a picture of a countersink hole which has obviously non-null values, but I can't find these values in the API.

 

Any help would be appreciated.

 

Thanks,

 

Philip

0 Likes
562 Views
2 Replies
Replies (2)
Message 2 of 3

nmunro
Collaborator
Collaborator

The attached part includes a VBA macro that should get you started. Run the routine from Tools > Macros on the ribbon. The code in the macro is listed below.

 

Public Sub HoleData()

Dim doc As PartDocument
Set doc = ThisDocument

Dim holeFeat As HoleFeature

For Each holeFeat In doc.ComponentDefinition.Features.HoleFeatures

       
    If holeFeat.HoleType = kCounterBoreHole Then 'you can check for other hole types with other conditional statements
        Dim holeDia As Parameter ' each numerical value associated with the hole is stored in a model parameter
        Dim cbDia As Parameter
        Dim cbDepth As Parameter
        
        Set holeDia = holeFeat.HoleDiameter
        Set cbDia = holeFeat.CBoreDiameter
        Set cbDepth = holeFeat.CBoreDepth
        
        'examine holeDia parameter
        Dim diaValue As Double
        diaValue = holeDia.Value 'internal value stored in cm
        diaValue = doc.UnitsOfMeasure.ConvertUnits(diaValue, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kInchLengthUnits) ' converted to inches
        
        Debug.Print holeFeat.Name & " - Diameter = " & diaValue
        
        ' use similar techniques to examine the other hole parameters
        
    End If


Next holeFeat

        


https://c3mcad.com

0 Likes
Message 3 of 3

Anonymous
Not applicable

Current update --

I am able to extract most of the cbore and csink holes successfully, however I am still getting an issue with finding the hole center.


This doesn't occur for all holes, just some, and I am not sure why. I have attached a picture showing that I have made a sketch point, upon which a HoleFeature (Hole3) is added.

For whatever reason:

for (int i = 0; i < holeFeat.HoleCenterPoints.Count; i++)
{
   if (holeSketch.SketchPoints[i + 1].HoleCenter)
      centerPts.Add(holeSketch.SketchPoints[i + 1].Geometry3d);

}

 

Does not return true for the hole, and it is skipped. 

 

Does anyone know why this is?

 

 

 

Screenshot 2021-04-14 154515.png

0 Likes