0

I'm attempting to activate the deactivated features.
I think if I get a Feature.activity parameter and change it to True from False, then I can activate all the decativated features.

Sub CATMain()

' On Error Resume Next

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 "CATPrtSearch.PartDesignFeature.Activity=FALSE,all"
    selection1.Search "CATPrtSearch.MechanicalFeature.Activity=FALSE,all"

    If selection1.Count = 0 Then
        MsgBox "No deactivated features"
        Exit Sub
 
    Else
        If MsgBox("The number of deactivated components is : " & selection1.Count & vbNewLine & "Click yes to activate or click no to exit.", vbYesNo) = vbYes Then
            
            For i = 1 To selection1.Count

**                'selection1.Item2(i).Activate

                selection1.Item2(i).MechanicalFeature.Activity=TRUE              
             
                'selection1.Item2(i).Value.Activity = True**
                
            Next 'i

            part1.Update

        End If

    End If

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

End Sub
Community
  • 1
  • 1
leeeeee
  • 3
  • 2
  • This post looks useful. https://stackoverflow.com/questions/60408714/kwa-catia-r24-activate-deactivate-components-by-script-problem-with-extrude – user10186832 Jan 02 '23 at 08:45
  • Welcome! Please take some time to read the introduction to Stack Overflow https://stackoverflow.com/tour – user10186832 Jan 02 '23 at 08:46
  • Just want to say manipulating activity parameters of features is a really bad practice. One or two you may bet away with. Cascading activity parameter manipulation never works well. – C R Johnson Jan 10 '23 at 13:24

2 Answers2

0

To active a feature you can use the method Activate from the part object. e.g.

part1.Activate(selection1.Item2(i).Value)

Be aware, if e.g. a sketch of a pad is also deacivated you get an error (your search doesn`t include sketches)

Shrotter
  • 350
  • 3
  • 9
0

Just to clarify a little more:

If you interactively deactivate a feature, the dialog box has a checkbox saying 'Deactivate aggregated elements'. If you uncheck this and deactivate a Pad, its sketch is NOT deactivated.

I recorded a macro and found out that depending on the above setting, the code explicitly deactivates / activates the sketch.

All sketch based features have .Sketch property. You can use that property to activate / deactivate sketch explicitly along with the feature.

Hope this helps.