API Issue - Generic Model Adaptive family instances don't get captured by .GetAddedElementIds()

alisa_sidko_M3
Participant
Participant

API Issue - Generic Model Adaptive family instances don't get captured by .GetAddedElementIds()

alisa_sidko_M3
Participant
Participant

I would like to report an issue concerning the behavior of Generic Model Adaptive FamilyInstances.

Specifically, they are not captured by .GetAddedElementIds() in combination with .GetChangeTypeElementAddition() or even outside of it.

The only elements recorded are ReferencePoints, and even then, the last placement point is omitted after the placement is finalized. With Adaptive family with no Placement Points - it records nothing. It's worth noting that the recorded points are temporary and get deleted once placement is complete. Furthermore, the only instance where new IDs are registered is through .GetModifiedElementIds(), but this occurs outside of .GetChangeTypeElementAddition(). And using .GetModifiedElementIds() as a workaround introduces too much of overhead for my intended purposes.


To my knowledge, this behavior is unique to Adaptive type of Generic Model Family.

To illustrate this issue, I've prepared a minimal Visual Studio solution along with a compiled .bundle. This setup interactively demonstrates the problem, confirming that it does not affect other Revit Elements (although further testing with additional elements has not yet been conducted). I have also included a small .rvt project with some families for testing. Given the interactive WPF components, creating a macro to handle this proved challenging, so I have provided a video demonstration instead.

Most of the code in the solution is just for the sake of intractability and logging. BackgroundApp.cs is where the aforementioned issues occur.

 

 

 

public void UpdaterSetup(Document doc)
{
  Dialog.Instance.Show();
  if (!updaterRegistered)
  {
    AddInId appId = doc.Application.ActiveAddInId;
    Guid updaterGuid = new Guid("E411B264-AF90-4E58-BEFA-29734BC7DEB8");

    MyElementAdditionUpdater updater = new MyElementAdditionUpdater(appId, updaterGuid);
    UpdaterRegistry.RegisterUpdater(updater);
    //AREA OF INTEREST
    //AREA OF INTEREST
    //AREA OF INTEREST
    UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), new ElementIsElementTypeFilter(true), Element.GetChangeTypeElementAddition());
    //AREA OF INTEREST
    //AREA OF INTEREST
    //AREA OF INTEREST

    // Update the flag to indicate the updater is registered
    updaterRegistered = true;
    Debug.Print("Updater has been registered.");
    handler = new HighlightElementEventHandler();
    ExEvent = ExternalEvent.Create(handler);
  }
}
public class MyElementAdditionUpdater : IUpdater
{
  private readonly UpdaterId _updaterId;

  public MyElementAdditionUpdater(AddInId addInId, Guid updaterGuid)
  {
    _updaterId = new UpdaterId(addInId, updaterGuid);
  }

  public void Execute(UpdaterData data)
  {
    Document doc = data.GetDocument();
    //AREA OF INTEREST
    //AREA OF INTEREST
    //AREA OF INTEREST
    foreach (ElementId addedElementId in data.GetAddedElementIds())
    //AREA OF INTEREST
    //AREA OF INTEREST
    //AREA OF INTEREST
    {
      Element addedElement = doc.GetElement(addedElementId);
      var elemInfo = new ElementInfo
      {
        ElementId = addedElementId.Value.ToString(),
        ElementType = addedElement.GetType().Name
      };

      // Add directly using the dialog's public method
      Dialog.Instance.AddElementInfo(elemInfo);
      Debug.Print($"Added Element ID: {addedElementId}, Type: {addedElement.GetType().Name}");
    }
  }
  public string GetAdditionalInformation() => "Handles addition of new elements";
  public ChangePriority GetChangePriority() => ChangePriority.FreeStandingComponents;
  public UpdaterId GetUpdaterId() => _updaterId;
  public string GetUpdaterName() => "Custom Element Addition Updater";
}

 

 

 


I would appreciate some guidance on how to submit this issue to the development team, as I can't imagine this being the intended result. I've been unable to find a way to do so with my trial ADN account. Unless I'm able to create the case through normal means, should I direct this to Technical Product Support instead? 

Thanks.

0 Likes
Reply
Accepted solutions (1)
526 Views
4 Replies
Replies (4)

alisa_sidko_M3
Participant
Participant

Ouch that video uploaded in real low quality. I'm unsure of how else others upload their videos to the forum with steps and timelines. But here's the re-up on the video.

And here's Steps to reproduce/highlight the issue:

  1. Place any type of element, in any quantity, into the model Test.rvt
  2. Place "Adaptive Generic" family of Generic Models type from Test.rvt. To access it you might need to rely on Project Browser list, find the family, right click on the type "Adaptive" and select Create Instance.
  3. Or even create Generic Model Adaptive type family with simple extrusion with no Placement Points and just load it into Test.rvt and place into model, the only thing to get logged in that scenario is the act of loading Family but not FamilyInstance.
  4. Compare the results, Adaptive types simply do not get logged, RevitLookup Event Monitor reflect same behavior.
  5. You can confirm the authenticity of what gets logged by selecting the entity from the list, if the element exists in the project it will be selected, and it's status field would reflect that, if the element could not be found/or its been deleted the status would update to read "Doesn't exist"

This isn't tied to just Test.rvt the code could be tested on any project, with any element, but the issue for me is that I need Adaptive families to get logged just like any other element in the Revit.

0 Likes

alisa_sidko_M3
Participant
Participant

Bump

0 Likes

jeremy_tammik
Autodesk
Autodesk
Accepted solution

I see a related issue in the development database. Maybe the following notes can help clarify your issue. Have you tested in Revit 2025? It is marked as resolved in this version: 

  

  • REVIT-117129 [DMU detects newly created adaptive elements as ModifiedElementIds rather than GetAddedElementIds - case 13063477]

  

Its current status is closed, fixed, resolved in Revit 2025.

  

Release Note: Fixed an API issue where the Dynamic Model Update ElementAddition event could not be triggered on

Customer's plugin contains an Updater (Dynamic Model Updater) which is responsible for doing one process when a family instance is added and another process when a family instance is modified. They are facing an issue with families that are created using the Generic Model Adaptive template. These adaptive families are not detected by the Updater when a Family Instance is inserted into(drag and drop) the document. The updater detects it as modified element when it is drag and drop into the document which is wrong because it is added (its ElementId is part of GetModifiedElementIds() collection when it is inserted into the document which is wrong. Its ElementId should be part of GetAddedElementIds() in this case ).

   

Reproduced the issue: The new elements are not reported as added at all even if the updater is set to react to added elements only. Other families behave as expected. As a workaround I hope it's possible to define application logic (at least for now ) by looking at the modified notification only for adaptive families. I assume you mark the family instances that you care about somehow ( like setting a certain user parameter ) and you'll have to take this into account and execute the 'creation' code when the family instance is modified for the first time. For older projects that already have some family instances that you care about , you probably want to execute the 'creation code' anyway first time you encounter them. And then rely on your mark and make sure you only execute 'modify' specific code.

    

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

alisa_sidko_M3
Participant
Participant

I'll be sure to test it, once I figure how to migrate the project to 2025.

RevitLookUp tool shows that it's recognizing the added Family Instance of Adaptive family in 2025, as it should.

Any idea if the fix will be rolled out to previous versions of Revit 2024-2022? My organization would rather do bi-annual updates.

0 Likes