List of Registered Display Conduits?

Is there a way to get a list of the display conduits that are being called? And remove items from the list?

The reason I’d like that is as follows:

We have a plug-in which draws in the viewports using a display conduit. Our plug-in is constantly under development, and… uh, it sometimes crashes. Which leaves the display conduit still running and rendering in Rhino until we fully close Rhino and restart it. Painful if you are iterating developing…

What I’d like to do, when our plug-in starts, is get a list of the display conduits currently being called. If I find a previous version running, I remove it. That would keep us from having to close and re-open Rhino.

Any hope for this? (I know, I know… the answer is don’t let the plug-in crash :slight_smile: )

Mark

Are you running the conduit only during a command? Or is it running when the plug-in loads and always active?

If only active during a command it can be easily disabled and disposed in the finally statement of a try-catch block. That way it is always disabled and disposed, whatever happens.

#command starts here

conduit = new Conduit()
try:
    # do stuff
except:
    # an exception occurred
finally: 
    conduit.Enabled = False
    conduit.Dispose()

#command ends here

PS. this is in Python, but the same applies in e.g. VB.NET and C#

1 Like

We toggle the conduit on/off as the user changes a Simulate checkbox in the UI. So it’s potentially always running as the plug-in’s GUI is up.

And we could definitely shut it down as you show if we could catch all the exceptions. It’s just tricky chasing a moving target. The program is constantly under development because it’s used for research and new features and changes happen all the time. Sort of an unusual software development situation.

Thanks for the response.

Mark

What do you mean by this? If your plug-in is just first being loaded, there is no chance that it had previous conduits running. I’m confused:)

Well if I run Rhino, then run our plug-in for the first time, then there is indeed no possibility of a previous conduit running.

But… If I run the plug-in once and it is drawing in the viewport… and then the plug-in crashes. Then the plug-in is not running but our display conduit did not shut down. So it is still rendering. Then I run the plug-in again, and the old version of the conduit is still running. In fact I can’t even use Rhino at all because the display conduit is still rendering - so I have to close the whole program.

So I’d like to just make a utility script to clear out the old one so I can continue to use Rhino w/o the robot being drawn. Or, if I run our plug-in again, check if a previous one is still there. And if so kill it off.

As I stated in the original post… the obvious answer is not to crash (or catch the exception and shut down the conduit)! But somehow that seems beyond us at times :smile:

If there is not a way to get a list of the running display conduits never mind… I just thought if there was I’d take advantage of it.

Mark

You should be able to just stick your conduit (or list of conduits) in the scriptcontext.sticky dictionary. Then your utility script can use that list.

Kick ass, it works :smile:

This is what we do at the top when putting up the UI now:

    # See if there is an existing conduit. If so kill it
    if scriptcontext.sticky.has_key("SMT_DC"):
        prevDC = scriptcontext.sticky["SMT_DC"]
        prevDC.Enabled = False
        prevDC.Dispose()
    
    # Make a new display conduit
    self.dc = DisplayConduit()
    scriptcontext.sticky["SMT_DC"] = self.dc

Thanks,
Mark

1 Like