PartUtils.FindMergeableClusters finds clusters which are not valid valid for merge

PartUtils.FindMergeableClusters finds clusters which are not valid valid for merge

schnierer.gabor
Advocate Advocate
1,227 Views
9 Replies
Message 1 of 10

PartUtils.FindMergeableClusters finds clusters which are not valid valid for merge

schnierer.gabor
Advocate
Advocate

Hello,

 

The docs say, the Autodesk.Revit.DB.PartUtils.FindMergeableClusters method returns an array of clusters such that all the elements in a single cluster are valid for merge. Each cluster will be maximal in that appending any of the other Parts specified as input will result in a collection that is not valid for merge.

 

I would assume executing the PartUtils.CreateMergedPart method on the clusters would run without issues. In the attached example project, the 3 parts marked on the screenshot are returned in one cluster making the CreateMergedPart method fail.

582f6184-459f-413e-a9e9-cec697779869.png

Revit_2023-11-27_09-17-46.png

 

I tried checking the cluster using the PartUtils.ArePartsValidForMerge method, but strangely it returns true for this cluster. Docs say, the method returns true if all element ids correspond to Part elements, none of the parts already has associated parts, the parts have contiguous geometry, all report the same materials, and all have the same creation and demolition phases. In my eyes, these parts don't have contiguous geometry. 

Is there something I overlook? 
For me it looks like a bug. My dev account doesn't allow me to submit an ADN API support case atm, as soon as I get it fixed, I'll post their reply in this thread.
Here is the ExternalCommand code I'm executing:

 

[Transaction(TransactionMode.Manual)]
internal class Command : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        var doc = commandData.Application.ActiveUIDocument.Document;
        var clusters = PartUtils.FindMergeableClusters(doc, new List<ElementId>()
        {
            new ElementId(682228),
            new ElementId(682229),
            new ElementId(682230),
            new ElementId(682231),
        });
        for (int i = 0; i < clusters.Count; i++)
        {
            TaskDialog.Show("Cluster Test", 
                $"Custer {i+1} of {clusters.Count}:" + Environment.NewLine +
                $"Number of parts in cluster: {clusters[i].Count}" + Environment.NewLine +
                $"Are parts valid for merge: {PartUtils.ArePartsValidForMerge(doc, clusters[i])}");

            if (PartUtils.ArePartsValidForMerge(doc, clusters[i]))
            {
                using (var t = new Transaction(doc, "Merge Parts"))
                {
                    t.Start();
                    PartUtils.CreateMergedPart(doc, clusters[i]);
                    t.Commit();
                }
            }
        }
        return Result.Succeeded;
    }
}

 




0 Likes
Accepted solutions (1)
1,228 Views
9 Replies
Replies (9)
Message 2 of 10

jeremy_tammik
Alumni
Alumni

Dear Gábor,

  

Thank you for the clear description and reproducible case. I can use that to create a development ticket for you. There is no need for an additional DAS = Autodesk Developer Advocacy and Support case (formerly ADN = Autodesk Developer Network). Did you create that ticket already? What number os it, please, so I can pick it up and connect it with this thread? By the way, any thread that you submit here in the forum using your email address registered as a DAS member will be recognised as such and automatically escalated to us in the DAS team in case no one else addresses it first. At the same time, we address a larger audience here, more of your peers see it, are able to chip in and help, and more people see and profit from the answers we provide. Therefore, this is the preferred method to submit non-confidential DAS queries or requests on the Revit API like this.

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 10

schnierer.gabor
Advocate
Advocate

Thanks Jeremy for picking it up and for your explanation on how the system works! I haven't created a ticket yet.

0 Likes
Message 4 of 10

jeremy_tammik
Alumni
Alumni

Dear Gábor,

 

Thank you again for your report.

 

Sorry to hear about this.

 

I logged the issue REVIT-215870 [PartUtils.FindMergeableClusters returns invalid clusters] 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 crucial. Our engineering team has limited resources and 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 Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 5 of 10

schnierer.gabor
Advocate
Advocate
Dear Jeremy, any updates maybe?
0 Likes
Message 6 of 10

jeremy_tammik
Alumni
Alumni

Dear Gabor,

  

Yes, you are in luck, things are moving ahead:

   

  • Changes on 08/Dec/23 10:13 AM:
    • Sprint: S23-22 ends Dec 22
    • Story Points: 1
  • Changes on 11/Dec/23 12:32 PM
    • Assignee: nominated

  

That is all the information I have so far.

  

Thank you for your patience.

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 7 of 10

jeremy_tammik
Alumni
Alumni

Dear Gábor,

  

Another update: The development team identified need for a code fix. They closed the issue REVIT-215870 [PartUtils.FindMergeableClusters returns invalid clusters] and opened a new ticket REVIT-216644 [PartUtils.FindMergeableClusters returns invalid clusters] to perform this work, saying that ArePartsValidForMerge does not check the clusters thoroughly enough. This will be solved in a future release. Please make a note of this number for future reference.

 

Best regards,

  

Jeremy

     

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 8 of 10

schnierer.gabor
Advocate
Advocate

Dear @jeremy_tammik, any updates maybe? I checked in Revit 2025 (25.0.2.419) and still experience the error.

0 Likes
Message 9 of 10

jeremy_tammik
Alumni
Alumni
Accepted solution

Dear Gábor,

 

Thank you for checking. The development team have completed work on REVIT-216644 [PartUtils.FindMergeableClusters returns invalid clusters] and submitted a fix that is planned for integration in the first Revit 2025 update release. As always, no guarantees!

 

Best regards,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 10 of 10

schnierer.gabor
Advocate
Advocate

Thanks Jeremy, I can confirm that the issue was corrected in Revit 2025.1

0 Likes