Snapshot data

Hi,

we want to implement a tool which extracts the information of a snapshot. To be more specific, we would need the position, layer state and visibility of an object in a snapshot. Also we would like to compare snapshots, if there is a difference in transformation of an object. So it would be great if we could retrieve this information without restoring the snapshot and analyze the document.

My question: is there a way to get this information via C++ SDK?

ok, seems to be a dead end.

another approach would be to implement our own snapshot client. Unfortunately the documentation is not that clear to understand how to use IRhinoSnapshotsClient. I achieved to register it and to get the callbacks. But i’m struggling to save the snapshot data in the document with the buffer. Do you have any example in C++ for this?

Thanks

@dsw

  1. It is not possible to extract the data at the moment. It is on our To-Do list but we will not get to it any time soon.

  2. You could do something like this to save, restore your data:

bool SaveDocument(CRhinoDoc& doc, ON_Buffer& buffer) override
{
	ON_BinaryArchiveBuffer archive(ON::archive_mode::write, &buffer);
	archive.WriteInt(2);
	return true;
}

bool RestoreDocument(CRhinoDoc& doc, const ON_Buffer& buffer) override
{
	ON_Buffer bufferCopy(buffer);

	int iValue = 0;

	ON_BinaryArchiveBuffer archive(ON::archive_mode::read, &bufferCopy);
	archive.ReadInt(&iValue);
	return true;
}

-Lars

Thank you @lars for the fast reply.

about 1) got it, sad though.

about 2) how about the RestoreObject, SaveObject and ObjectTransformNotification. i got it working for one snapshot, but if there are more snapshots everything gets messed up. Do you have any example there?

Thanks

What exactly does “everything gets messed up” mean?
Would it be possible to share your code?

-Lars

Hi @lars ,

of course, here is what i’ve done so far:

virtual bool SaveObject(CRhinoDoc& doc, const CRhinoObject& obj, const ON_Xform& xformObject, ON_Buffer& buffer)
{
	buffer.SeekFromStart(0);
	buffer.Write(16 * sizeof(double), xformObject.m_xform);

	return true;
};

virtual bool RestoreObject(CRhinoDoc& doc, const CRhinoObject& obj, const ON_Xform& xformObject, const ON_Buffer& buffer)
{
	ON_Xform xform;

	ON_Buffer buffer2(buffer);
	buffer2.SeekFromStart(0);
	buffer2.Read(16 * sizeof(double), xform.m_xform);

	doc.TransformObject(&obj, xform.Inverse(), true, true, false);

	return true;
};

virtual bool ObjectTransformNotification(CRhinoDoc& doc, const CRhinoObject& obj, const ON_Xform& xformObject, ON_Buffer& buffer)
{
	ON_Xform xform;
	buffer.SeekFromStart(0);
	buffer.Read(16 * sizeof(double), xform.m_xform);

	xform = xformObject * xform;

	buffer.SeekFromStart(0);
	buffer.Write(16 * sizeof(double), xform.m_xform);

	return true;
}

it seems to work for one snapshot, but if you create another one, it restores the object on the wrong place.
Any idea what i’m doing wrong?

Thanks

Remove the code from the ObjectTransformNotification function. You can use the transform xformObject which is getting passed into the RestoreObject function instead. xformObject are all transforms which got applied to the object since it got into contact with Snapshots. In RestoreObject you could read your xform out of the buffer as you already do and multiply it with the inverse of xformObject.

–Lars

Wow, it’s so easy if you know what the parameters are for. :wink:

@lars i have still on point to finalize my feature: i need to know this specific data in the “buffer” from the SaveObject in relation to the snapshot itself, so that i can say “Snapshot 01” has the same transformation as “Snapshot 02”.
At the moment i could store the information of the buffer in an array, but i have no idea which snapshot belongs to which transformation in the array? Because the interface IRhinoSnapshotsClient does not give me a name of the snapshot. Also i’m not aware if the name of a snapshot changes.

Do you have any clue how i can fill the gap and find a link between the “buffer” data and the snapshot, or to be more specific: do you know how i can find the current saving and restoring snapshot name in SaveObject and RestoreObject?

I am afraid that is not possible at the moment.

Ok, i already thought so. Looks like i have to make another workaround…

Thanks