Missing HideInDetail() python function

Greetings,
I am attempting to hide multiple objects in multiple details within several layouts of a rhino file.
I have got a test script functions correctly, however I have had to use rs.Command(“_HideInDetail”).
The problem is, my current method takes a long time to hide large numbers of objects across several layouts and details. I assume there must a way to gain access to the HideInDetail functionality without using the Rhino command line, but I have not been able to locate it in the docs.

Any assistance would be extremely helpful, below is my test code complete with command line functions.
Thanks

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext

def HideInDetails(Objs):
    for layout in scriptcontext.doc.Views.GetPageViews():       #Get all layouts in document
        scriptcontext.doc.Views.ActiveView = layout             #Set layout to active view
        for detail in layout.GetDetailViews():                  #Get all detail in each layout
            if detail.DetailGeometry.IsProjectionLocked==True:  #Test if deatil is locked
                detail.DetailGeometry.IsProjectionLocked=False  #Lock detail so we can edit it
                detail.CommitChanges()                          #Unlock the detail 
            layout.SetActiveDetail(detail.Id)                   #Set detail to active
            
            ## Would like to accomplish this in rhino common ##
            rs.SelectObjects(Objs)                              #Select Items we dont want to see in detail
            rs.Command("_HideInDetail")                         #Hide everything you dont want to see in the detail
            rs.Command("_SelNone")                              #Clear selection

objs=rs.GetObjects("Select objects to hide in all details")
if objs: HideInDetails(objs)

If you just do this manually, using the HideInDetail command, does it (also) take a long time? If so, re-writing the command in RhinoCommon isn’t going to speed things up…

Dale,
Thanks for the quick reply. I did a quick test to check which operation was taking the most time and it was the selection command which selects the objects before HideInDetail is called. After modifying the script to add in a couple timers it came back with the following results:

Number of objects:1
HideInDetail timer: 0.124786376953
Select objects timer: 0.0935897827148

Number of objects:8
HideInDetail timer: 0.0780029296875
Select objects timer: 0.639625549316

Number of objects:27
HideInDetail timer: 0.109191894531
Select objects timer: 2.21517181396

Number of objects:64
HideInDetail timer: 0.093620300293
Select objects timer: 5.47750091553

Number of objects:125
HideInDetail timer: 0.10920715332
Select objects timer: 11.8618316650

Number of objects:216
HideInDetail timer: 0.187973022461
Select objects timer: 23.8121566772

Number of objects:343
HideInDetail timer: 0.313987731934
Select objects timer: 35.6105422974

As you can see the amount of time spent waiting for objects to be selected is much greater with higher object counts while the time spent waiting for all the objects to be hidden is minimal. This makes me think that if I could pass the object guids directly into some sort of HideInDetail function without having to select them it would speed up this process.

Thanks,
5chmidt

def HideInDetails(Objs):
    s_timer=0
    h_timer=0
    for layout in scriptcontext.doc.Views.GetPageViews():       #Get all layouts in document
        scriptcontext.doc.Views.ActiveView = layout             #Set layout to active view
        for detail in layout.GetDetailViews():                  #Get all detail in each layout
            if detail.DetailGeometry.IsProjectionLocked==True:  #Test if deatil is locked
                detail.DetailGeometry.IsProjectionLocked=False  #Lock detail so we can edit it
                detail.CommitChanges()                          #Unlock the detail 
            layout.SetActiveDetail(detail.Id)                   #Set detail to active
            
            start=time.time()           #Start selection timer
            rs.SelectObjects(Objs)      #Select objects 
            end=time.time()             #Stop selection timer
            s_timer+=end-start          #Record selection timer
            
            start=time.time()           #Start hide timer
            rs.Command("_HideInDetail") #HideInDetail
            end=time.time()             #End hide timer
            h_timer+=end-start          #Record hide
            
            rs.Command("_SelNone")
    
    print "Number of objects:"+str(len(Objs))
    print "HideInDetail timer: "+str(h_timer)
    print "Select objects timer: "+str(s_timer)
    print

Does turning off screen redrawing help?

rs.EnableRedraw(False)
HideInDetails()
rs.EnableRedraw(True)

Yes, turning off redrawing helps, in the past I tend to have unexpected things happening when I turn off redraw when using command line functions. In general I have tried to avoid it, but in this case it seems to work fine.

Dale,
For this example it is not necessary, but if it is possible, I would be interested to know how to HideInDetail using Rhino common rather than having to call a command line function.
Thanks,
5chmidt

The functionality required to do what HideInDetails does is not available in RhinoCommon at this time.

Hi Dale,

How would one addhidedetailoverride in a python script?

Sorry learning python atm and making automation for architecture manufacturing processes. Aiming to select object, create new layout, create detail, isolate object in detail, create top,front,side section views of object and automatic dimension them. Big task.

Hi @lukehickmandesign,

Use ObjectAttributes.AddHideInDetailOverride.

You might consider creating your objects on different layers and then turning layers on/off in details using Layer.SetPerViewportVisible. A “better” organizational approach than hiding objects in details.

– Dale

1 Like

Thanks Dale, The only issue is doing shop drawings when you isolate a select part. The part would normally be on a layer with a collection of similar parts. Having a layer per part becomes to hard.

Also, I am struggling to toggle the attribute addhideindetailoverride

Could you please give me a short example. This is what i am using now:

Rhino.DocObjects.ObjectAttributes.AddHideInDetailOverride(obj,True) (edit)

Dont worry got it sorted.I couldnt figure our attribute method, would be great if there was a rhinoscript syntax for python.

I got my function working using this method:

if obj_ref:

    select_all_objects_except_one(obj)      
    
    
    rs.Command("_HideInDetail")
    """ 
    attributes = obj_ref.Attributes
    if attributes:
        attributes.AddHideInDetailOverride(obj) == False
        obj_ref.CommitChanges()
        """
    
    rs.SelectObject(obj)
    rs.ZoomSelected()
    doc.Views.Redraw()

Here is another example:

import Rhino
import scriptcontext as sc

def TestHideInDetail():
    page_view = sc.doc.Views.ActiveView
    if not isinstance(page_view, Rhino.Display.RhinoPageView):
        print('The active view is neither a layout nor a detail view.')
        return
    
    detail_view = page_view.ActiveDetail
    if not detail_view:
        print('The active view is not a detail view.')
        return
    
    viewport_id = detail_view.Id
    
    filter = Rhino.DocObjects.ObjectType.AnyObject
    rc, objrefs = Rhino.Input.RhinoGet.GetMultipleObjects("Select objects to hide", False, filter)
    if rc != Rhino.Commands.Result.Success:
        return
    
    for objref in objrefs:
        obj = objref.Object()
        if obj:
            attributes = obj.Attributes.Duplicate()
            attributes.AddHideInDetailOverride(viewport_id)
            sc.doc.Objects.ModifyAttributes(obj.Id, attributes, False)
    page_view.Redraw()
    

if __name__ == "__main__":
    TestHideInDetail()

– Dale

Cheers thanks Dale.