# Tracking Transforms (BeforeTransformObjects Event)

**URL:** <https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480>\
**Category:** Rhino Developer\
**Tags:** windows, rhinocommon, python, rhino7\
**Created:** [April 21, 2022, 9:51pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480 "2022-04-21T21:51:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakemurphy0118](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jakemurphy0118/32/670324_2.png) [@jakemurphy0118](https://discourse.mcneel.com/u/jakemurphy0118)\
**Post date:** [April 21, 2022, 9:51pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480/1 "2022-04-21T21:51:37Z")

</div>

I would like to track all the transformations which occur to certain objects in Rhino from import to purge.

I discovered that a python script which calls rhinoscriptsyntax.MoveObjects(object\_ids, translation) produces events:  
ReplaceRhinoObject  
DeleteRhinoObject  
AddRhinoObject

but no BeforeTransformObjects event.

Is this intended behavior and are there other situations in which objects are transformed but do not produce this event?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [April 21, 2022, 10:33pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480/2 "2022-04-21T22:33:50Z")

</div>

> [@doc.Objects.Transform don't fires the RhinoDoc.BeforeTransformObjects event](https://discourse.mcneel.com/t/doc-objects-transform-dont-fires-the-rhinodoc-beforetransformobjects-event/80055):
>
> Hello, I think that there is a bug in RhinoDoc.BeforeTransformObjects event. It seems that the event is fired only if the transformation of the objects is done directly by the user using the Rhino commands. Instead, if I try to transform the document’s objects with doc.Objects.Transform(obj\_ref, xform, true) in a custom command, the event RhinoDoc.BeforeTransformObjects is not fired. Is it a bug or is it the correct behaviour? Thanks in advance

---

<div class="post-metadata">

**Author:** ![jakemurphy0118](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jakemurphy0118/32/670324_2.png) [@jakemurphy0118](https://discourse.mcneel.com/u/jakemurphy0118)\
**Post date:** [April 21, 2022, 11:21pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480/3 "2022-04-21T23:21:45Z")

</div>

Thank you.

Is the method RhinoObject.OnTransform(Transform transform) also only called or triggered by commands that inherit from TransformCommand?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [April 21, 2022, 11:43pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480/4 "2022-04-21T23:43:43Z")

</div>

Hi @jakemurphy0118,

Yes, I believe this is the case.

Commands that inherit from `TransformCommand` include Move, Copy, Scale, etc.

– Dale

---

<div class="post-metadata">

**Author:** ![jakemurphy0118](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jakemurphy0118/32/670324_2.png) [@jakemurphy0118](https://discourse.mcneel.com/u/jakemurphy0118)\
**Post date:** [April 22, 2022, 12:58pm UTC](https://discourse.mcneel.com/t/tracking-transforms-beforetransformobjects-event/141480/5 "2022-04-22T12:58:26Z")

</div>

I discovered that RhinoObject.OnTransform is called following a call to rhinoscriptsyntax.MoveObjects while BeforeTransformObjects does not fire. I’ve attached a plugin and script to help demonstrate this.  
[TrackingTransforms.zip](https://discourse.mcneel.com/uploads/short-url/mwcjAH4nJ22EeiubglgC2YVWnzo.zip) (35.0 KB)  
[centerObject.py](https://discourse.mcneel.com/uploads/short-url/nn5unGxqq8zszX8QZPR8t1IbzoI.py) (569 Bytes)

I might be able to use the custom object method to track transformations; however, this feels inconsistent and not what you would expect based on the RhinoDoc events.

Edit:  
Yes, you can do this with CustomObjects. Instead of performing accounting of transforms in BeforeTransformObjects handlers, perform the accounting in the custom object’s OnTransform overridden method.
