Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4125

Finding objects hidden by clipping plane in viewport

$
0
0

I have a script which adds text on the objects visible in a detail. The script includes a method which determines which objects are visible in the detail. This works great except with clipping planes. Any objects hidden by a clipping plane get the text, which they should not. Does anyone know how to determine which objects in a detail are hidden by a clipping plane?

Here is the method:

def _is_object_in_viewport(obj, viewport, clippingPlanes):
    """
    Check if an object is visible in the viewport.
    """    
    layer_for_obj = sc.doc.Layers[obj.Attributes.LayerIndex]
    if not layer_for_obj.PerViewportIsVisible(viewport.Id):
        return False
    if obj.Attributes.HasHideInDetailOverrideSet(viewport.Id):
        return False    
    bbox = rs.BoundingBox(obj)        
    does_contain = True
    for p in bbox:
        does_contain = viewport.GetFrustumBoundingBox().Contains(p)
        if not does_contain:
            break
    return does_contain

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4125