- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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;
}
}
Solved! Go to Solution.
Developer Advocacy and Support +