Our custom parts that need to be changed to standard should always have a feature added instead of the original part being changed. That's because the ones I am targeting are wood parts, paneling parts, etc. If it has a miter or other cutouts, it needs to stay custom. But if it was just put in as custom because nobody at my company knew how to use standard parts until a few years ago, it should go back to standard.
So feature count should be 99.9% foolproof for our usage.
The problem I had with save counter is that in testing, I found standard parts from the same family with different FileSaveCounter values for some reason. I also had custom parts that had added features that had the same FileSaveCounter value as the standard part.
Because the parts in question also do not have conditional features as standard parts, how I've ended up doing my check is I determine if the part is a custom content center part, and then I place a temporary member of the family, check whether the number of features matches the part being tested, and then delete the temporary part. Here's a test version of my code for those who may be interested:
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Return
'Let user pick a part occurrence from the assembly
Dim oCCmember As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a component, press esc when complete")
'Get document for the part the user picked
Dim oPartDoc As Document = oCCmember.Definition.Document
Logger.Info("Custom and can be changed to Standard? = " & IsCustom_CanBeStandard(oPartDoc))
End Sub
''' <summary>
''' Determine whether the part is a custom content center part that can be changed to standard.
''' </summary>
''' <param name="PartDoc">The part document being checked</param>
''' <returns>True if the part in question can be changed from custom to standard</returns>
Private Function IsCustom_CanBeStandard(ByVal PartDoc As PartDocument) As Boolean
If Not (PartDoc.PropertySets.PropertySetExists("ContentCenter") AndAlso PartDoc.PropertySets("ContentCenter").Item("IsCustomPart").Value = "1") Then
Return False 'return false if part is either not content center or is standard part
End If
'continue if it is a custom content center part...
'get part content family object
Dim cf As ContentFamily = ThisApplication.ContentCenter.GetContentObject("v3#" & PartDoc.PropertySets("Content Library Component Properties").Item("FamilyId").Value & "#")
Dim ee As MemberManagerErrorsEnum
Dim featureCheck As Boolean
Try
ThisApplication.ScreenUpdating = False
'create and place a standard part of the same family as the part in question
Dim testOcc As ComponentOccurrence = CType(ThisDoc.Document, AssemblyDocument).ComponentDefinition.Occurrences.Add(cf.CreateMember(1, ee, "Problem"), ThisApplication.TransientGeometry.CreateMatrix())
featureCheck = testOcc.Definition.Document.ComponentDefinition.Features.Count = PartDoc.ComponentDefinition.Features.Count 'true if picked part features match the standard part
testOcc.Delete2(True) 'delete the test item without saving
Catch ex As Exception
Logger.Info("Error Trying to Check Standard Part Feature Count: " & ex.Message)
Return False 'there was some kind of error so don't change the part
Finally
ThisApplication.ScreenUpdating = True
End Try
Return featureCheck
End Function