Hi;
Can anyone give me an example of how to use CRhinoOnTransformObject in c++ ?
Hi;
Can anyone give me an example of how to use CRhinoOnTransformObject in c++ ?
Hi,
I’ve used it in Bongo and it’s fairly straightforward. You’ll need to create a class that inherits from CRhinoOnTransformObject. That in turn inherits from CRhinoEventWatcherEx so you have access to Register and Enable to set it up. The Notify override is called when a transform event has happened. The CRhinoOnTransformObject::CParameters passed into Notify gives you a list all the objects and grips that are being transformed as well as the transformation being applied.
class CYourOnTransformObject : CRhinoOnTransformObject
{
public:
CYourOnTransformObject () : CRhinoOnTransformObject(Your_PlugIn_Id) { }
~CYourOnTransformObject () { }
void Notify(const class CRhinoOnTransformObject::CParameters& params) override
{
//Your logic here
}
};
From there it’s as simple as creating and registering an instance and enabling it when you need it to be.
Hi@Joshua_Kennedy;
Thank you for your help.
I still don’t quite understand, I want to get the Transformation when have some object move, roatate or scale, I have try to do that in OnReplaceObject event, but failed
class CRhinoEventWatcher : public CRhinoEventWatcher
{
void OnReplaceObject( CRhinoDoc& doc, CRhinoObject& old_object, CRhinoObject& new_object );
};
void CRhinoEventWatcherr::OnReplaceObject(CRhinoDoc& doc, CRhinoObject& old_object, CRhinoObject& new_object)
{
CYourOnTransformObject my;
}
class CYourOnTransformObject : CRhinoOnTransformObject
{
public:
CYourOnTransformObject() : CRhinoOnTransformObject(ON_UuidFromString(L"5D281573-6581-4227-A72A-FD5DFEB1F3B7")) { }
~CYourOnTransformObject() = default;
void Notify(const class CRhinoOnTransformObject::CParameters& params) override
{
RhinoApp().Print(L"%d\n", params.m_object_count);
}
};
Hi @pythonuser,
This on on CRhinoOnTransformObject::CParameters
:
// Transformation that will be applied
ON_Xform m_xform;
for example:
void CTestOnTransformObject ::Notify(const class CRhinoOnTransformObject::CParameters& params)
{
ON_Xform xform = params.m_xform;
// todo...
}
Is this what you are looking for?
– Dale