.NET

Reply
Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 1 of 3 (5,407 Views)
Accepted Solution

VB.NET: Deleting Custom Properties using SheetSet Manager API in VB.NET

5407 Views, 2 Replies
10-29-2013 06:45 AM

I currently use code similar to Lee Ambrosius's 2009 AU handout that shows how to set/create custom properties.  It can be seen here http://adndevblog.typepad.com/autocad/2013/09/using-sheetset-manager-api-in-vbnet.html, search for the header 'Adding Sheet Set and Sheet Properties'.

 

I have now accumulated numerous unused custom properties in my sheet set.  I haven't been able to find a way to delete these additional custom properties.

 

Because I use multiple subsets with multiple sheets for printing, I would rather not have to go through all the sheets, store all the custom properties I need, destroy all the existing custom properties, and then re-create just the ones I need.

 

Any suggestions on how to delete individual custom properties would be helpful.

 

MEP 2012 with VB.NET

 

Thanks

Hi John,

 

Can you please try using "IAcSmCustomPropertyBag.SetProperty" and pass a null custom property value ?

 

Here is a sample code to remove a few custom properties

 

 sheetSetMgr = New AcSmSheetSetMgr
Dim iterDb As IAcSmEnumDatabase
iterDb = sheetSetMgr.GetDatabaseEnumerator
Dim ItemDb As IAcSmPersist
ItemDb = iterDb.Next
sheetdb = ItemDb
LockDatabase()
Dim cBag As IAcSmCustomPropertyBag
cBag = sheetdb.GetSheetSet().GetCustomPropertyBag()
Dim enumeratorProperty As IAcSmEnumProperty
enumeratorProperty = cBag.GetPropertyEnumerator()
enumeratorProperty.Reset()
Dim name As String = ""
Dim customPropertyValue As AcSmCustomPropertyValue = Nothing
enumeratorProperty.Next(name, customPropertyValue)
Dim customPropNames As System.Collections.Specialized.StringCollection
customPropNames = New System.Collections.Specialized.StringCollection
customPropNames.Add("Test3")
customPropNames.Add("Test6")
Do While Not customPropertyValue Is Nothing
If customPropertyValue.GetFlags() = PropertyFlags.CUSTOM_SHEETSET_PROP And customPropNames.Contains(name) Then
cBag.SetProperty(name, Nothing)
End If
enumeratorProperty.Next(name, customPropertyValue)
Loop
UnlockDatabase()

 

Regards,

ADN Support Specialist
Balaji_Ram
Posts: 737
Registered: ‎03-21-2011
Message 2 of 3 (5,373 Views)

Re: VB.NET: Deleting Custom Properties using SheetSet Manager API in VB.NET

10-30-2013 10:35 PM in reply to: CommCorp

Hi John,

 

Can you please try using "IAcSmCustomPropertyBag.SetProperty" and pass a null custom property value ?

 

Here is a sample code to remove a few custom properties

 

        sheetSetMgr = New AcSmSheetSetMgr

        Dim iterDb As IAcSmEnumDatabase
        iterDb = sheetSetMgr.GetDatabaseEnumerator

        Dim ItemDb As IAcSmPersist
        ItemDb = iterDb.Next

        sheetdb = ItemDb

        LockDatabase()

        Dim cBag As IAcSmCustomPropertyBag
        cBag = sheetdb.GetSheetSet().GetCustomPropertyBag()

        Dim enumeratorProperty As IAcSmEnumProperty
        enumeratorProperty = cBag.GetPropertyEnumerator()
        enumeratorProperty.Reset()

        Dim name As String = ""
        Dim customPropertyValue As AcSmCustomPropertyValue = Nothing

        enumeratorProperty.Next(name, customPropertyValue)

        Dim customPropNames As System.Collections.Specialized.StringCollection
        customPropNames = New System.Collections.Specialized.StringCollection
        customPropNames.Add("Test3")
        customPropNames.Add("Test6")

        Do While Not customPropertyValue Is Nothing

            If customPropertyValue.GetFlags() = PropertyFlags.CUSTOM_SHEETSET_PROP And customPropNames.Contains(name) Then
                cBag.SetProperty(name, Nothing)
            End If

            enumeratorProperty.Next(name, customPropertyValue)
        Loop

        UnlockDatabase()

 

Regards,



Balaji
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
CommCorp
Posts: 104
Registered: ‎03-19-2007
Message 3 of 3 (5,360 Views)

Re: VB.NET: Deleting Custom Properties using SheetSet Manager API in VB.NET

10-31-2013 05:28 AM in reply to: Balaji_Ram

Using the statement 'cBag.SetProperty(name, Nothing)' did the trick.

 

Thank You

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!