Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
HideoYamada
in reply to: Jef_E

Hello Jef_E,

 

This code will refresh the first hole feature in the active part document.

Option Explicit

Sub test()
    Dim pCompDef As PartComponentDefinition
    Set pCompDef = ThisApplication.ActiveEditDocument.ComponentDefinition
    
    Dim holeFt As HoleFeature
    Set holeFt = pCompDef.Features.HoleFeatures(1)
    
    ' Add/Remove methods of HoleFeature.HoleCenterPoints will be ignored.
    ' So we must create new ObjectCollection and then replace with it.

    Dim centers As ObjectCollection
    Set centers = ThisApplication.TransientObjects.CreateObjectCollection
    Dim dot As SketchPoint
    For Each dot In holeFt.Sketch.SketchPoints
        If dot.HoleCenter Then
            centers.Add dot
        End If
    Next
    
    holeFt.HoleCenterPoints = centers
    
    Debug.Print holeFt.HoleCenterPoints.Count
End Sub

By the way, I do same thing by using Sketch Driven Pattern.

It automatically follows adding/removing hole centers, and can be used for Pattern Component in the assembly.

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp