.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deleting / resetting custom properties, help needed

1 REPLY 1
SOLVED
Reply
Message 1 of 2
adamkalajzich
662 Views, 1 Reply

Deleting / resetting custom properties, help needed

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.

 

1 REPLY 1
Message 2 of 2

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost