0

I m trying to inactivate the edge fillet and chamfer feature to simplify the CATIA model. I made the macro code as follow.

However, obiously, if the other features refer the fillet or chamfer, the part cannot be updated.

Thus, I want to inactivate the all children features, but I cannot find how to get the children relationship of selected feature.

Please give me help or insight to solve this problem

Thank you for your help

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

If Err.Number = 0 Then
    Dim selection1 As Selection
    Set selection1 = partDocument1.Selection
    
    selection1.Search "Name=*fillet*,all"
    
    If selection1.Count = 0 Then
        MsgBox "No fillet features"
        
    Else
        For i = 1 To selection1.Count
            part1.Inactivate (selection1.Item2(i).Value)
        Next 'i
        'part1.Update
    End If
    
    Dim selection2 As Selection
    Set selection2 = partDocument1.Selection
    
    selection2.Search "Name=*chamfer*,all"
    
    If selection2.Count = 0 Then
        MsgBox "No chamfer features"
        
    Else
        For j = 1 To selection2.Count
            part1.Inactivate (selection2.Item2(j).Value)
        Next 'j
        'part1.Update
    End If
    
    part1.Update
    
    MsgBox ( tot_f_c_num & " features are inactivated.")

Else
    MsgBox "Not a part document! Open a single part document."
End If

End Sub
leeeeee
  • 3
  • 2
  • afaik there is no method to get the children of a feature by a macro. You could try to loop trough: update, check if part is updated, if not search for the feature which fails, deactivate this feature, restart loop – Shrotter Jan 16 '23 at 15:50
  • You are now discovering that my comment in your other question is true: Manipulating feature activity is a dark hole of doom. If you have KWA then there are ways to do what you want. But not by manipulating activity parameters. – C R Johnson Jan 19 '23 at 13:00
  • @Shrotter I cant also find any related reference. I will try again considering your comments. Thank you for your help. – leeeeee Jan 25 '23 at 07:43
  • @CRJohnson Now I truly know. But we dont have KWA license thus I tried to manipulating feature activity for model simplification in CATIA. Thank you for your reply – leeeeee Jan 25 '23 at 07:44

1 Answers1

0

@Shrotter I modified my macro as follow; it seems to work well at this time, but may have problem ::

Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
If Err.Number = 0 Then
    Dim selection1 As Selection
    Set selection1 = partDocument1.Selection
    selection1.Search "Name=*fillet*,all"
    If selection1.Count = 0 Then
        MsgBox "No fillet features"
    Else
        For i = 1 To selection1.Count
            part1.Inactivate (selection1.Item2(i).Value)
        Next 'i
    End If
    Dim selection2 As Selection
    Set selection2 = partDocument1.Selection
    selection2.Search "Name=*chamfer*,all"
    If selection2.Count = 0 Then
        MsgBox "No chamfer features"
    Else
        For j = 1 To selection2.Count
            part1.Inactivate (selection2.Item2(j).Value)
        Next 'j
    End If
    Dim selection3 As Selection
    Set selection3 = partDocument1.Selection
    selection3.Search "Name=*,all"
    For k = 1 To selection3.Count
        On Error Resume Next
        part1.UpdateObject (selection3.Item2(k).Value)
        If Err.Number <> 0 Then
            part1.Inactivate (selection3.Item2(k).Value) 
        End If
    Next 'k
Else
    MsgBox "Not a part document! Open a single part document."
End If
End Sub
leeeeee
  • 3
  • 2