Enable DisplayConduit after Rhino Is Open (C++)

Hi;
In this sample,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?

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

What is you conduit supposed to provide?

– Dale

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

#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

but in the cmdsample_dispaly.cpp

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