Display Pipeline and DrawZebraPreview problem

Hello, as you see in the video ZebraPreview always visible even the brep is not connected or recompute the solution , and when i open ghpython editor and click ok or test the brep disappears
How to fix this code?

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino as rh
import rhinoscriptsyntax as rs

class CurveColor(component):

    def RunScript(self,b,c):
        
        if not b: return
        if not c: c = System.Drawing.Color.White
        
        self.b = b
        self.c = c
        
        bb = b.GetBoundingBox(True)

        self.bb = bb

    def DrawViewportWires(self,arg):
        arg.Display.DrawZebraPreview(self.b, self.c)

    def get_ClippingBox(self):
        return self.bb
        
    def IsPreviewCapable(self):
        return True

zebra.gh (3.6 KB)

Hi @anon39580149,

Try this:

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino as rh
import rhinoscriptsyntax as rs

class CurveColor(component):
    def RunScript(self,b,c):
        self.b = b
        if self.b:
            self.bb = b.GetBoundingBox(True)
        else:
            self.bb = rh.Geometry.BoundingBox.Empty
        self.c = c
        if not self.c:
            c = System.Drawing.Color.White
    
    def DrawViewportWires(self,arg):
        if self.b:
            arg.Display.DrawZebraPreview(self.b, self.c)
    
    def get_ClippingBox(self):
        return self.bb
        
    def IsPreviewCapable(self):
        return True

– Dale

2 Likes

Thank you @dale for the solution

Hi Dale, is it possible to change the pink stripes to other colors? It seems the script only has input c for one color of the Zebra effect

It seems the stripe color is changed in the popup of the Zebra command–I changed it to pink from black

You can change these settings programatically.

https://developer.rhino3d.com/api/rhinocommon/rhino.applicationsettings.zebraanalysissettings

– Dale

1 Like

Thanks so much for your help! Getting zebra stripes from GH speed things up for me a lot! :running_man:t3: