Hello all,
I have been programming our document and version control values into the sheet set object, as a result the custom property list per drawing is getting a little large and is becoming a bit hard to manage. There are now properties with values that are no longer needed. Is there a way to delete or clear or maybe reset the customproperty bag per sheetset object / sheet object?
I have been playing around with code that looks like this:
Private Sub DeleteCustomProperties(ByRef myItem As IAcSmPersist, Optional ByVal Lock As Boolean = True) ''Throw New NotImplementedException Dim myDB As AcSmDatabase = myItem.GetDatabase Try Select Case myItem.GetTypeName Case "AcSmSheetSet" If True Then Dim mySheetset As AcSmSheetSet = myItem mySheetset.GetCustomPropertyBag.Clear() End If Exit Select Case "AcSmSheet" If True Then Dim mySheet As AcSmSheet = myItem mySheet.GetCustomPropertyBag.Clear() End If Exit Select End Select Catch ex As Exception End Try End Sub
but when i get to "set" the new custom properties (which works normaly when updating a custom property or adding a custom property to a custom propertybag that I have not "cleared"), I am getting a object not set to an instance error...
Do I have to "recreate" the custom propertybag with the InitNew(ByVal pOwner as IAcSmPersist).
Any help greatly apreciated.
Merry Christmas and a happy new year to you all.
Solved! Go to Solution.
Solved by adamkalajzich. Go to Solution.
sorry, I worked it out... solution attached: (yes it was the initnew)
Private Sub DeleteCustomProperties(ByRef myItem As IAcSmPersist, Optional ByVal Lock As Boolean = True) ''Throw New NotImplementedException Dim myDB As AcSmDatabase = myItem.GetDatabase Try Select Case myItem.GetTypeName Case "AcSmSheetSet" If True Then Dim mySheetset As AcSmSheetSet = myItem mySheetset.GetCustomPropertyBag.Clear() mySheetset.GetCustomPropertyBag.InitNew(myItem) End If Exit Select Case "AcSmSheet" If True Then Dim mySheet As AcSmSheet = myItem mySheet.GetCustomPropertyBag.Clear() mySheet.GetCustomPropertyBag.InitNew(myItem) End If Exit Select End Select Catch ex As Exception End Try End Sub