Solidworks Macro - Uitsluiting in selectie

Hallo

Ik heb een functie in een macro die onderdelen selecteert op basis van eigendom, om die onderdelen vervolgens naar een map te verplaatsen.

Het probleem is dat het ook de delen selecteert onder de beperkingen nr. 1 op de bijgevoegde afbeelding waarvan de symmetrische of repetitieve delen en vooral degene die problemen veroorzaakt, de delen in een riemfunctie zijn, zie nr. 2. (zie waarom aan het einde van het onderwerp)

Is het mogelijk om bij het selecteren niet alles onder de beperkingen te selecteren of in ieder geval niet te selecteren wat in een beperkingsfunctie zit?

Bijgevoegd is mijn code:

Sub TraverseComponent(swComp As SldWorks.Component2, nLevel As Long, catSelect As String)
    Dim vChilds As Variant, vChild As Variant
    Dim swChildComp As SldWorks.Component2
    Dim MyString As String
    Dim swCustPropMgr As SldWorks.CustomPropertyManager
    Set swApp = Application.SldWorks

    
    vChilds = swComp.GetChildren
    For Each vChild In vChilds
        Set swChildComp = vChild
        Dim FileName As String
        FileName = swChildComp.GetPathName
        Debug.Print "Part Name    : " & FileName
        FileName = Left(FileName, InStr(FileName, ".") - 1)
        FileName = Right(FileName, Len(FileName) - InStrRev(FileName, "\"))
        Debug.Print "Part Name    : " & FileName
        MyString = FileName
        Dim ActiveConfig As String
        ActiveConfig = swChildComp.ReferencedConfiguration
        Debug.Print "Configuration: " & ActiveConfig
        FileName = swChildComp.GetPathName
        If swChildComp.GetSuppression() <> swComponentSuppressionState_e.swComponentSuppressed Then
            Dim swPart As SldWorks.modelDoc2
            Set swPart = swChildComp.GetModelDoc2()
            'Récupère la catégorie de la configuration active
            Set swCustPropMgr = swPart.Extension.CustomPropertyManager(ActiveConfig) 'get properties
            categorie = swCustPropMgr.Get("Categorie") 'get categorie
            designation = swCustPropMgr.Get("Designation")
            'Si la catégorie de la config active est vide on récupère celle du document
            If categorie = "" Then
                Set swCustPropMgr = swPart.Extension.CustomPropertyManager("") 'get properties
                categorie = swCustPropMgr.Get("Categorie") 'get categorie
                If designation = "" Then
                    designation = swCustPropMgr.Get("Designation") 'get categorie
                End If
            End If
            
            Debug.Print "Catégorie: " & categorie
            
            If catSelect = "FI" Then
                folderName = "FI"
                If (categorie = "Fourniture Industrielle" And Not (designation Like "STD*")) Or (categorie = "Tuyauterie") Or ((categorie = "Sans Catégorie") And (MyString Like "Bipod*")) Or ((categorie = "Sans Catégorie") And (MyString Like "Tripod*")) Then
                    compteur = compteur + 1
                    retVal = swChildComp.Select2(True, 0)
                End If
             ElseIf catSelect = "Visserie" Then
                folderName = "Visserie"
                Debug.Print "Type:" & swPart.GetType
                If (categorie = "Visserie") Or ((categorie = "Sans Catégorie") And (swPart.GetType = 2) And (Not MyString Like "Bipod*") And (Not MyString Like "Tripod*")) Then
                    compteur = compteur + 1
                    retVal = swChildComp.Select2(True, 0)
                End If
             ElseIf catSelect = "Reconductible" Then
                folderName = "Reconductible"
                'If categorie = "Reconductible" Then
                If (categorie = "Reconductible") And (Not designation Like "STD*") Then
                    compteur = compteur + 1
                    retVal = swChildComp.Select2(True, 0)
                End If
             ElseIf catSelect = "Electricite" Then
                folderName = "Electricité"
                If categorie = "Electricite" Then
                    compteur = compteur + 1
                    retVal = swChildComp.Select2(True, 0)
                End If
            
              ElseIf catSelect = "STD" Then
                folderName = "STD"
                If designation Like "STD*" Then
                    compteur = compteur + 1
                    retVal = swChildComp.Select2(True, 0)
                End If
                
            End If
            
        End If
        Debug.Print
    Next

End Sub

 

 

 

Inderdaad, in Solidworks is er een bug: als u het deel in een riemfunctie selecteert dat u met de rechtermuisknop klikt om toe te voegen aan de nieuwe map, staat het deel van deze functie zowel boven de beperkingen als eronder (visueel - zie bijgevoegd bestand)

Indien nodig voeg ik ook de volledige macro toe.

 


createfolderbyproperties.swp
dbggtzkwq9.gif