How to update extensible storage when I change the point cloud?

How to update extensible storage when I change the point cloud?

ywkimPXXW3
Participant Participant
359 Views
2 Replies
Message 1 of 3

How to update extensible storage when I change the point cloud?

ywkimPXXW3
Participant
Participant

I want to modify the extensible storage when there are changes such as moving or rotating the point cloud.

 

It seems impossible in DocumentChangedEvent.

 

I found the Updater, but I can't get into the execute.

 

I've used both filters.

 

 

namespace TestPointCloud
{
    class App : IExternalApplication
    {
        static string ExecutingAssemblyPath = System.Reflection.Assembly
  .GetExecutingAssembly().Location;

        AddInId addinId;

        public Result OnStartup(UIControlledApplication a)
        {
            addinId = a.ActiveAddInId;
            
            ControlledApplication ctrlApp = a.ControlledApplication;
            ctrlApp.DocumentOpened += new EventHandler<DocumentOpenedEventArgs>(CtrlApp_DocumentOpened);
            
            return Result.Succeeded;
        }

        private void CtrlApp_DocumentOpened(object sender, DocumentOpenedEventArgs e)
        {
            TextUpdater updater = new TextUpdater(addinId);
            UpdaterRegistry.RegisterUpdater(updater);
            //ElementCategoryFilter pointCloudFilter = new ElementCategoryFilter(BuiltInCategory.OST_PointClouds);
            ElementClassFilter pointCloudFilter = new ElementClassFilter(typeof(PointCloudType));
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), pointCloudFilter, Element.GetChangeTypeGeometry());
        }

        
        public Result OnShutdown(UIControlledApplication a)
        {
            return Result.Succeeded;
        }
    }

    public class TextUpdater: IUpdater
    {
        AddInId addinId;
        UpdaterId updaterID;
        public TextUpdater(AddInId id)
        {
            addinId = id;
            updaterID = new UpdaterId(addinId, new Guid("FBF3F6B2-4C06-42d4-97C1-D1B4EB593EFF"));
        }

        public void Execute(UpdaterData data)
        {
            int test = 1;
        }

        public string GetAdditionalInformation() { return "N/A"; }
        public ChangePriority GetChangePriority() { return ChangePriority.GridsLevelsReferencePlanes; }
        public UpdaterId GetUpdaterId() { return updaterID; }
        public string GetUpdaterName() { return "TestUpdater"; }
    }
}

 

 

0 Likes
360 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

You are absolutely right: this cannot be done in the DocumentChanged event handler.

 

Please read the documentation:

 

https://www.revitapidocs.com/2021.1/f7acc5b4-a1b4-12ca-802b-0ee78942589e.htm

  

This event is raised whenever a Revit transaction is either committed, undone or redone. This is a readonly event, designed to allow you to keep external data in synch with the state of the Revit database. To update the Revit database in response to changes in elements, use the IUpdater framework.
  
Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

ywkimPXXW3
Participant
Participant

Thank you for reply.

 

I try to use IUpdater.

 

There is no error when I AddTrigger, and I can stop at GetUpdaterName using break point when changes occur.

 

But, I can't stop at Execute function.

 

Please let me know what's wrong.

0 Likes