Hello,
I am wondering if there is a way to allow the user to select items, but to prevent the user from changing anything of these objects.
Basically I want to lock the objects, but still allow the user to select them.
Is there any way to do this in Rhino?
Thank you!
Let me clarify - I just want this to happen while a form of my plugin is open.
I am considering responding to the following events and “undoing” their change if the object is to be “locked”.
RhinoDoc.DeleteRhinoObject += RhinoDoc_DeleteRhinoObject;
RhinoDoc.ReplaceRhinoObject += RhinoDoc_ReplaceRhinoObject;
RhinoDoc.BeforeTransformObjects += RhinoDoc_BeforeTransformObjects;
RhinoDoc.ModifyObjectAttributes += RhinoDoc_ModifyObjectAttributes;
In the end I managed by listening to the Add and Delete events.
private void RhinoDoc_AddRhinoObject(object sender, RhinoObjectEventArgs e)
{
// Automatically deletes the object
string typeString = e.TheObject.Attributes.GetUserString("T");
if (!string.IsNullOrEmpty(typeString))
{
if (typeString == SoftwareObjectType.FrameTheoretical.GetObjectTypeAbbreviation() ||
typeString == SoftwareObjectType.InnerJointTheoretical.GetObjectTypeAbbreviation() ||
typeString == SoftwareObjectType.ModelJointTheoretical.GetObjectTypeAbbreviation())
{
// Should re-add the theoretical object
e.TheObject.Attributes.SetUserString("TAD", "1"); // Setting a flag for the delete event so that it doesn't re-add
StructuralLidarPluginData.Doc.Objects.Delete(e.TheObject);
}
}
}
private void RhinoDoc_DeleteRhinoObject(object sender, Rhino.DocObjects.RhinoObjectEventArgs e)
{
// Readds the object
string typeString = e.TheObject.Attributes.GetUserString("T");
if (!string.IsNullOrEmpty(typeString))
{
if (typeString == SoftwareObjectType.FrameTheoretical.GetObjectTypeAbbreviation() ||
typeString == SoftwareObjectType.InnerJointTheoretical.GetObjectTypeAbbreviation() ||
typeString == SoftwareObjectType.ModelJointTheoretical.GetObjectTypeAbbreviation())
{
// Re-adds only if it is not the theoretical object being auto-deleted
if (e.TheObject.Attributes.GetUserString("TAD") != "1") StructuralLidarPluginData.Doc.Objects.Undelete(e.TheObject);
}
}
}
To answer your question, no, there is not.
– Dale
That would be a great addition.