Subcategories in families refuse to delete via the API

Subcategories in families refuse to delete via the API

aricke59
Enthusiast Enthusiast
1,242 Views
7 Replies
Message 1 of 8

Subcategories in families refuse to delete via the API

aricke59
Enthusiast
Enthusiast

I have some families that have a long history of upgrades. Some of the subcategories are now redundant or need to be renamed.

 

The issue I have is that some subcategories (no not system ones) cannot be deleted via the API (they can be deleted via the UI). I suspect this is due to the Revit release that they were first created in.

 

Note: I use something like doc.delete(catID) to delete the categories. This works for some user defined subcategories and not for others.

 

If I create new subcategories (named the same after I use the UI to delete the API undeletable subcategory) the subcategories can be deleted / renamed. This is a MASSIVE issue for my clients who have many such old families.

 

I experience this issue in Revit 2014, 15, 16, 17, & 18.

 

Any help would be much appreciated. I am reasonably certain an adjustment to the Revit code is required.

 

Note: These subcategories can be deleted via the User Interface.

 

I have attached a family that shows the issue. QF_Clearances, QF_Cutout Details, and some other subcategories cannot delete via the api.

0 Likes
1,243 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Dear Andreas,

 

Thank you for your report and sample RFA.

 

Sorry to hear about this.

 

You omit to say exactly how the deletion fails. What happens instead? Could you possibly add a macro to the RFA you provide, to implement a full reproducible case?

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

I logged the issue REVIT-112757 [API unable to delete subcategory in family whereas UI works] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 8

aricke59
Enthusiast
Enthusiast

Hi Jeremy, thanks for the response. 

 

A routine replicating the issue has been uploaded. 

 

I need to highlight that this impacts many content management users. The need to delete (or rename) subcategories due to changed industry standards is common and affects thousands (if not millions) of older families. Imagine opening a thousand families and deleting (or renaming) four subcategories in each family. Also the somewhat random nature of the fault makes it very frustrating and unpredictable as to when it will fail or succeed.

 

Regards, Andreas

0 Likes
Message 4 of 8

aricke59
Enthusiast
Enthusiast

Here is a sample routine. Have the previously uploaded family open when you run this.

 

Public Shared Function deleteCategory(catName As String, subCat As String, localDoc As Document) As Boolean

        'Get the category

        catName = "Specialty Equipment"

        subCat = "QF_Clearances"

        Dim cats As Autodesk.Revit.DB.Settings = localDoc.Settings()

        Dim catForDelete As Category

        'Find matching main category

        Try

            If subCat = "" Then

                catForDelete = cats.Categories.Item(catName)

            Else

                Dim cat As Category = cats.Categories.Item(catName)

                catForDelete = cat.SubCategories.Item(subCat)

            End If

        Catch ex As Exception

            'May be a builtincategory

            Return False

        End Try

        Dim t As New Transaction(localDoc, "Delete Cat")

        If Not localDoc.IsModifiable Then t.Start()

        Try

            Dim ids As New List(Of ElementId) : ids.Add(catForDelete.Id)

            localDoc.Delete(ids)

            MsgBox("Delete successful")

        Catch ex As Exception

            MsgBox("Delete FAILED" & vbCrLf & ex.Message)

        End Try

        If t.HasStarted Then t.Commit()

    End Function

 

Running this results in

 

 

If I delete the QF_Clearances subcategory via the UI, then recreate it, and re-run the routine, I get

 

 

It would appear that there is some legacy data (or lack of new data) that prevents deletion of the previously defined subcategory.

 

Kind regards,

 

Andreas Ricke

0 Likes
Message 5 of 8

jeremytammik
Autodesk
Autodesk

Dear Andreas,

Thank you for your sample code and images.

I added them with your notes to the issue REVIT-112757 [API unable to delete subcategory in family whereas UI works] for the development team to analyse.

Best regards,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 6 of 8

jeremytammik
Autodesk
Autodesk

Dear Andreas,

 

Thank you for your patience.

 

The development team have taken a look at the issue REVIT-112757 [API unable to delete subcategory in family whereas UI works] and confirm:

 

This issue is understandable and reproducible. Yes, this is related to old families.

 

They reassigned it to the appropriate team for further investigation.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 8

Anonymous
Not applicable

Has this been resolved in Revit 2019?

0 Likes
Message 8 of 8

Anonymous
Not applicable

It looks like the issue is resolved in 2019

0 Likes