For whatever reason, whenever I run the below macro (as a macro feature running on rebuild) on a mirrored part it changes nothing. It should be deleting and replacing the material property with some text.
Example of a thicknessmaterial would be "0.250-ASTM A36" so Material would read "ASTM A36".
(The custom property thicknessmaterial actually equals the SW Material. We do this to control the color by using the SW material and color is determined by grade and thickness. A future macro feature I want to make is to control the color automatically by cross referencing the sheetmetal thickness and SW Material, but this does explain this problem...)
Function swmRebuild(varApp As Variant, varDoc As Variant, varFeat As Variant) As Variant
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim App As SldWorks.SldWorks
Dim Doc As SldWorks.ModelDoc2
Dim feat As SldWorks.Feature
Dim FeatData As SldWorks.MacroFeatureData
Dim Rebuild As Boolean
Dim val As String
Dim valout As String
Dim bool As Boolean
Dim Position As Long
Dim Length As Long
Set App = varApp
Set Doc = varDoc
Set feat = varFeat
Set swCustPropMgr = Doc.Extension.CustomPropertyManager("")
bool = swCustPropMgr.Get4("ThicknessMaterial", False, val, valout)
Position = InStr(1, valout, "-")
Length = Len(valout)
MsgBox swCustPropMgr.Count
bool = swCustPropMgr.Delete2("Material")
If (0 < Position) Then
Doc.AddCustomInfo2 "Material", swCustomInfoText, Right(valout, Length - Position)
Else
Doc.AddCustomInfo2 "Material", swCustomInfoText, valout
End If
Set evHdlr = New EventHandler
Rebuild = True
End Function
I found a way around this by deleting the custom property "Material" out of my part template. But I see this is a dumb work around, and I see other people having problem with mirrored parts custom properties with macros and I am not confident enough to know that I am doing it right.
SolidworksApi macros