Error "Third party updater "WatchUpdaterWidows" has experienced a problem and its action had to be canceled." when use DMU

Error "Third party updater "WatchUpdaterWidows" has experienced a problem and its action had to be canceled." when use DMU

068335643
Advocate Advocate
583 Views
3 Replies
Message 1 of 4

Error "Third party updater "WatchUpdaterWidows" has experienced a problem and its action had to be canceled." when use DMU

068335643
Advocate
Advocate

I try to use DMU in my code and it works (I need to type parameters and write to the element instance) But when I change something in the type (not related to the geometry) everything breaks and this error pops up. 

068335643_0-1642169940629.png

   class WatchUpdaterWidows : IUpdater
    {
        static AddInId _appId;
        static UpdaterId _updaterId;

        public WatchUpdaterWidows(AddInId id)
        {
            _appId = id;

            _updaterId = new UpdaterId(_appId, new Guid(
              "fafbf6b2-4c06-42d4-97c1-d1b4eb593eff"));
        }

        public void Execute(UpdaterData data)
        {
            Document doc = data.GetDocument();
            Application app = doc.Application;


            foreach (ElementId id in data.GetModifiedElementIds())
            {
                var listWindows = new List<Element>();
                FamilyInstance familyInstance = doc.GetElement(id) as FamilyInstance;
                listWindows.Add(familyInstance);
                new WindowParamertSet(listWindows, doc, WindowParamertSet.UseCase.SetError);


                //if (familyInstance != null)
                //{
                //    if (data.IsChangeTriggered(id, Element.GetChangeTypeParameter(new ElementId(BuiltInParameter.LOAD_COMMENTS))))
                //    {
                //        break;
                //    }

                //}



            }


        }

        public string GetAdditionalInformation()
        {
          return  "Constrol.Com";
        }

        public ChangePriority GetChangePriority()
        {
            return ChangePriority.DoorsOpeningsWindows;
        }

        public UpdaterId GetUpdaterId()
        {
            return _updaterId;
        }

        public string GetUpdaterName()
        {
            return "WatchUpdaterWidows";
        }
    }
}
       public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;




            if (null == updater)
            {

                var updater = new WatchUpdaterWidows(app.ActiveAddInId);

                UpdaterRegistry.RegisterUpdater(updater);

                ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Windows);

                UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeGeometry());
                
            }

            else
            {
                UpdaterRegistry.UnregisterUpdater(updater.GetUpdaterId());
                updater = null;
            }   
            
            return Result.Succeeded;
                

            
        }
    }
}

Waht's  wrong?

0 Likes
584 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

Your updater has an error.

 

Please try to debug it.

 

One possible reason: you are generating an infinite recursion. I.e., you react to a change, perform a modification in your updater, that causes a change, that calls your updater again, etc., ad infinitum.

  

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

Sean_Page
Collaborator
Collaborator

I think the issue you are experiencing is that you are only filtering on a category, which can include the Types of the windows as well. Since you are casting it directly to a FamilyInstance its breaking.

 

Try something like this to check if you have a Family first.

if(doc.GetElement(id) is FamilyInstance familyInstance)
{
    listWindows.Add(familyInstance);
    new WindowParamertSet(listWindows, doc, WindowParamertSet.UseCase.SetError);
}
Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 4 of 4

ivo.lafeber
Enthusiast
Enthusiast

I have the same problem, I have 2 lists of builtin categories which also creates this error. 

 

el is the selected element 

 

If E_Category_List.Contains(el.Category.BuiltInCategory) Or GM_Category_List.Contains(el.Category.BuiltInCategory) Then

 

 changed it to this line, the builtincategory was the problem in the line above

the contains was oke, but, that's what chatgpt answered when I asked to remove the contains function in the line above :). 

 

If E_Category_List.IndexOf(CType(el.Category.Id.IntegerValue, BuiltInCategory)) <> -1 Or GM_Category_List.IndexOf(CType(el.Category.Id.IntegerValue, BuiltInCategory)) <> -1 Then

 

 

 

 

0 Likes