Specify Coordinates at Point, Relocate Project does not trigger IUpdater

Specify Coordinates at Point, Relocate Project does not trigger IUpdater

JOfford_13
Advocate Advocate
1,045 Views
3 Replies
Message 1 of 4

Specify Coordinates at Point, Relocate Project does not trigger IUpdater

JOfford_13
Advocate
Advocate

I have setup an IUpdater to monitor the X,Y,Z coordinates of certain elements which triggers on Element.GetChangeTypeGeometry().  I then grab the current position of each element using something like the following.

 

void Foo(Element element, ProjectLocation projectLocation = null)
{
     if (element.Location is LocationPoint locationPt)
     {
         double x, y, z;

         if (projectLocation != null)
         {
              var projectPosition = projectLocation.GetProjectPosition(locationPt.Point);

              x = projectPosition.EastWest;
              y = projectPosition.NorthSouth;
              z = projectPosition.Elevation;
         }
         else
         {
              var pt = locationPt.Point;

              x = pt.X;
              y = pt.Y;
              z = pt.Z;
         }
         // do stuff here ..
     }
}

This works great except the user clicks "Specify Coordinates At Point" or "Relocate Project".  That command modifies all the project position values but the IUpdater fails to trigger.  Is there any way to detect when these commands are run?  If not, is there anything that can be done to the IUpdater that would make it fire after these events?

0 Likes
1,046 Views
3 Replies
Replies (3)
Message 2 of 4

JimJia
Alumni
Alumni

 Hi JOfford_13,

Position changed will not trigger the Updater. Following is from API document:

 

"GetChangeTypeGeometry Method

Use this change type to trigger an Updater when the geometry of an element changes. Only physical changes to shape of the element(s) will trigger the updater. For example, changes like cutting a hole in a wall or adjusting its height are considered to be geometric changes. However, moving a wall to a different location without modifying its shape is not considered to be a change in geometry and will not trigger the Updater."
 
If you want to catch the event, you need to use Element.GetChangeTypeAny() Method. .

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: [email protected]
0 Likes
Message 3 of 4

JOfford_13
Advocate
Advocate

The documentation for GetChangeTypeGeometry is not accurate.  The following IUpdater configuration will trigger when a FamilyInstance is moved in Revit 2018.2.

 

var filter = new FamilyInstanceFilter(doc, familySymbolId);

UpdaterRegistry.AddTrigger(updaterId, filter, Element.GetChangeTypeGeometry());

Element.GetChangeTypeAny() does work in catching the base point movements however I discovered the following also works and probably has less overhead.

 

var filter = new ElementClassFilter(typeof(BasePoint));

UpdaterRegistry.AddTrigger(updaterId, filter, Element.GetChangeTypeAny());
0 Likes
Message 4 of 4

JOfford_13
Advocate
Advocate

any update on this?

0 Likes