# Enable DisplayConduit after Rhino Is Open (C++)

**URL:** <https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481>\
**Category:** Rhino Developer\
**Created:** [September 21, 2018, 6:42pm UTC](https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481 "2018-09-21T18:42:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pythonuser](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pythonuser/32/593905_2.png) [@pythonuser](https://discourse.mcneel.com/u/pythonuser)\
**Post date:** [September 21, 2018, 6:42pm UTC](https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481/1 "2018-09-21T18:42:18Z")

</div>

Hi;  
[In this sample](https://github.com/mcneel/rhino-developer-samples/blob/master/cpp/SampleCommands/cmdSampleDrawWireframeMesh.cpp),if I want to enable the displayconduit when the PlugIn load,and the it draw the mesh after mesh get a value by CRhinoGetObject.

How cant I do this, is it some sample?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [September 21, 2018, 10:47pm UTC](https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481/2 "2018-09-21T22:47:05Z")

</div>

Just curious, why would you not want to create your conduit on demand?

What is you conduit supposed to provide?

– Dale

---

<div class="post-metadata">

**Author:** ![pythonuser](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/pythonuser/32/593905_2.png) [@pythonuser](https://discourse.mcneel.com/u/pythonuser)\
**Post date:** [September 22, 2018, 1:46am UTC](https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481/3 "2018-09-22T01:46:30Z")

</div>

Hi @dale;  
I want to draw some object after the PlugIn command end of run.  
So that, I do like this:

//DISP\_H.h

```
  #ifndef DISP_H
  #define DISP_H
  class CConduitDrawColorMesh : public CRhinoDisplayConduit
  {
	  public:
	    CConduitDrawColorMesh();
	    ~CConduitDrawColorMesh() {}

	  bool ExecConduit( 
			CRhinoDisplayPipeline& dp, // pipeline executing this conduit
			UINT nChannel, // current channel within the pipeline
			bool& bTerminate // channel termination flag
			);

	  const ON_Mesh* m_pMesh;
  };
  #endif

```

[//disp.cpp](https://disp.cpp)

```
#include "StdAfx.h"
#include "DISP_H.h"
CConduitDrawColorMesh::CConduitDrawColorMesh()
: CRhinoDisplayConduit( CSupportChannels::SC_CALCBOUNDINGBOX | CSupportChannels::SC_POSTDRAWOBJECTS )
{
}

bool CConduitDrawColorMesh::ExecConduit( 
        CRhinoDisplayPipeline& dp, 
        UINT nChannel, 
        bool& bTerminate 
        )
{
  // Get the rhino viewport attached to the display pipeline...
  CRhinoViewport& vp = dp.GetRhinoVP();
  
  // Determine which channel we're currently executing in...
  switch( nChannel )
  {
  case CSupportChannels::SC_CALCBOUNDINGBOX:
    {
      if( m_pMesh && m_pMesh->IsValid() )
      {
        ON_BoundingBox bbox;
        m_pMesh->GetTightBoundingBox( bbox, false );
        // Now adjust the channel attribute's bounding box with the accumulated one...
        m_pChannelAttrs->m_BoundingBox.Union( bbox );
      }
    }
    break;

  case CSupportChannels::SC_POSTDRAWOBJECTS:
    {
      if( m_pMesh && m_pMesh->IsValid() )
      {
        if( vp.DisplayMode() == ON::wireframe_display )
        {
          dp.DrawWireframeMesh( *m_pMesh, RGB(0,0,255) );
        }
        else
        {
          CDisplayPipelineMaterial mat;
          dp.SetupDisplayMaterial( mat, RGB(0,0,255) );
          dp.DrawShadedMesh( *m_pMesh, &mat );
        }
      }
    }
    break;
  }

  return true;
}

```

//sample\_dispalyPlugIn.cpp

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/8/9/891505c4d613c5fc97b3b39e3a51ac5233f02169.png)

but in the cmdsample\_dispaly.cpp

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/6/8/687e3a16f933474c2479a05ac0ae295d063cc0e0.png)

How cant I assign?

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [September 27, 2018, 4:49pm UTC](https://discourse.mcneel.com/t/enable-displayconduit-after-rhino-is-open-c/71481/4 "2018-09-27T16:49:50Z")

</div>

> [@pythonuser](#):
>
> How cant I assign?

In your sample, `conduit` is a variable you create on the stack. Thus, when the `OnLoadPlugIn` function finished, the variable is thrown away.

– Dale
