AnsweredAssumed Answered

Custom Properties Linked to Parent Part

Question asked by Andrea Orlando on Dec 12, 2018
Latest reply on Dec 13, 2018 by Andrea Orlando

Hi

 

I have the same problem of this thread: https://forum.solidworks.com/thread/93844

 

Manually it works. I want to implement it via VBA.

 

I want to check if an inserted part has the flag "Custom Properties" true and remove it.

 

I already remove other flag with this code:

Function CheckSubPart(swModelDoc As SldWorks.ModelDoc2, sFileNameCode As String) As Boolean
        CheckSubPart = False


        ' E' stato classificato come pezzo.
        Dim swFeat                      As SldWorks.Feature
        Dim FeatDefinition              As SldWorks.DerivedPartFeatureData
        Dim sFeatName                   As String
        Dim sFeatType                   As String
        Dim bSkipImportSurf             As Boolean
        
        Set swFeat = swModelDoc.FirstFeature
        bSkipImportSurf = False
        While Not swFeat Is Nothing
            sFeatName = swFeat.Name
            sFeatType = swFeat.GetTypeName
            'Debug.Print sFeatName + " [" + sFeatType + "]"
            
            Select Case sFeatType
                Case "Stock" ' Si tratta di una Parte Inserita
                    Debug.Print sFeatName + " [" + sFeatType + "]"
                    swModelDoc.Extension.SelectByID2 sFeatName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0
                    
                    Set FeatDefinition = swFeat.GetDefinition
                    
                    Debug.Print sFeatName + " = " + Str(FeatDefinition.ImportSurf)
                    If bAutomaticClean = True Then
                        If FeatDefinition.ImportSurf = 1 Then
                            bConfigurationChanged = True
                            
                            FeatDefinition.AccessSelections swModelDoc, Nothing
                            FeatDefinition.ImportSurf = 0
                            swFeat.ModifyDefinition FeatDefinition, swModelDoc, Nothing
                            FeatDefinition.ReleaseSelectionAccess
                            CheckSubPart = True
                        End If
                    Else
                        If FeatDefinition.ImportSurf = 1 And bSkipImportSurf = False Then
                            If swApp.SendMsgToUser2("ATTENZIONE: Il componente " + vbNewLine + vbNewLine + sFileNameCode + vbNewLine + vbNewLine + " contiene una Parte inserita (" + sFeatName + ") con l'opzione di Trasferimento 'Corpi di superficie' attiva." + vbNewLine + vbNewLine + "Questa opzione, quando attiva, può causare problemi durante la Codifica della Parte (elementi in quantità doppia)." + vbNewLine + vbNewLine + "Disattivare l'opzione ?" + vbNewLine + vbNewLine + "(rispondendo NO, l'opzione non viene modificata e non saranno mostrati ulteriori problemi di questo tipo, viceversa, saranno modificati in automatico tutti gli eventuali problemi individuati)", swMbWarning, swMbYesNo) = swMbHitYes Then
                                bConfigurationChanged = True
                                bAutomaticClean = True
                                
                                FeatDefinition.AccessSelections swModelDoc, Nothing
                                FeatDefinition.ImportSurf = 0
                                swFeat.ModifyDefinition FeatDefinition, swModelDoc, Nothing
                                FeatDefinition.ReleaseSelectionAccess
                                CheckSubPart = True
                            Else
                                bSkipImportSurf = True
                            End If
                        End If
                        
                        Set FeatDefinition = Nothing
                    End If
                    
                    ' Deseleziona
                    swModelDoc.Extension.SelectByID2 "", "", 0, 0, 0, False, 0, Nothing, 0
                ' * END CASE *
            End Select
            
            Set swFeat = swFeat.GetNextFeature
        Wend
End Function

but i don't find an interface like "FeatDefinition.ImportSurf = 0" to disable "Custom Properties".

 

Any ideas ?

(P.S.: SolidWorks 2018)

Outcomes