Hello all,
I’m wondering if there’s a method for hiding multiple objects in multiple layout details through Grasshopper. I’m currently using Drafthorse, but it cannot handle this specific case - it’s author published C# code that works very well for layers, but I need something that works for objects in this instance.
My first thought was retrieve the needed object GUIDs then call their AddHideInDetailOverride method with the corresponding detail view - while this seems to work in the Grasshopper document, the objects in the Rhino document do not update accordingly. Attached below is a screenshot of the code I wrote for this purpose:
Any help would be appreciated - thank you,
CH
Yes, this is for Rhino 8.
Have you tried the ‘new’ Grasshopper Rhino components yet?
Yes, though there’s still a lot to learn coming from R7. Is there a way to bake ModelObjects with the necessary detail view assigned to the HideInDetailOverride attribute?
I think they are still working on some layout components.
I’ve determined a solution, but now the issue is expiring the object list when updating the HideInDetailOverride attribute, which is what I’m assuming Drafthorse’s author also ran into. The code just needed a commit changes method to be ran after changing the attribute:
// Grasshopper Script Instance
#region Usings...
public class Script_Instance : GH_ScriptInstance
{
#region Notes...
private void RunScript(
Guid obj_guid,
Guid detail_view_guid,
bool is_active,
ref object a)
{
// Write your logic here
a = "Not active.";
if(is_active)
{
a = "Object GUID provided not found in document.";
Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;
Rhino.DocObjects.RhinoObject rh_obj = doc.Objects.FindId(obj_guid) as Rhino.DocObjects.RhinoObject;
if(rh_obj != null)
{
rh_obj.Attributes.AddHideInDetailOverride(detail_view_guid);
rh_obj.CommitChanges();
a = "Attribute added to " + rh_obj.Name;
}
}
}
}
I’ll either reply to this message with a full solution once or I’ll link to a solve thread once I find a solution.