C#ATIA

↑タイトル詐欺 主にFusion360API 偶にCATIA V5 VBA(絶賛ネタ切れ中)

お掃除する

これも無駄になった・・・。

"gDustBox" と言う名のグローバルなコレクション内の要素を
ひたすら削除するclean_up関数です!

Private gDustBox As Collection

Private Sub clean_up()

    Dim pt As Part
    Set pt = CATIA.ActiveDocument.Part

    Dim fact As HybridShapeFactory
    Set fact = pt.HybridShapeFactory

    Dim sel As Selection
    Set sel = CATIA.ActiveDocument.Selection

    CATIA.HSOSynchronized = False

    On Error Resume Next
        Dim ent1, ent2
        For Each ent1 In gDustBox
            Select Case TypeName(ent1)
                Case "Collection"
                    For Each ent2 In ent1
                        fact.DeleteObjectForDatum ent2
                    Next
                Case "HybridBody"
                    With sel
                        .Clear
                        .Add ent1
                        .Delete
                    End With
                Case Else
                    fact.DeleteObjectForDatum ent1
            End Select
        Next
    On Error GoTo 0

    CATIA.HSOSynchronized = True
End Sub