C++ SDK Some questions

Hello everyone, I have encountered some problems now:

The first question is:
I want to use Rhino C ++ SDK to write a DLL called by C#, Similar @dale Dale’s Moose,And successfully and happily run in Rhino6 &(wip)7,I tried to do the same thing on Rhino5,Normal run in Rhino5x64_d.exe,In the official version of Rhino5 to debug,VS: The specified module cannot be found:

System.DllNotFoundException:“Unable to load DLL"myDll.dll”: The specified module cannot be found. (Exception fromHRESULT:0x8007007E).

I am confused about this. I tried to find the answer on forums and search engines, but it still failed to be solved. Does anyone know how to solve it? Or can you provide a simple example?

The second question is: CRhinoDisplayConduit

bool CSweep2Conduit::ExecConduit(CRhinoDisplayPipeline& dp, UINT nChannel, bool& bTerminate)
{
    UNREFERENCED_PARAMETER(bTerminate);
    if (nChannel == CSupportChannels::SC_DRAWFOREGROUND)
    {
        ON_wString str;
        if (m_mixCount > 0)
        {
            for (int i = 0; i < m_pointsA.Count(); i++)
            {
                //Draw index
                str.Format(L"%d", i);
                dp.SetObjectColor(ON_Color(RGB(0, 0, 255)));
                dp.DrawString(str, m_pointsA[i], false, 18);
                //Draw point
                dp.DrawPoint(m_pointsA[i], 4, RPS_CONTROL_POINT,ON_Color(RGB(0, 0, 255)));
            }
        }
    }
    return true;
}

This code can display string well in (wip)7,But on Rhino6, a string is not displayed. DrawPoint Normal,I don’t know whether it is a bug or a problem with my code, or something else.

The third question is:

doc.AddPointCloudObject(conduit.m_mixCount, conduit.m_pointsA);

This code can add normal points in (wip)7,But in Rhino6, there will only be very small points.
I didn’t find the answer to the last two questions in the forum. I don’t know if I am the only one who has encountered such a problem.
Thank you!

Hi @Easy,

1.) Keep in mind that Rhino 5 came in both 32-bit and 64-bit versions. So make sure the target platform of your .NET assembly matches the target platform of the interop DLL you are trying to load. Also make sure all assemblies are int eh same output folder.

2.) This is probably a better implementation of ExecConduit:

bool CTestEasyConduit::ExecConduit(
	CRhinoDisplayPipeline& dp, 
	UINT nChannelID, 
	bool&
)
{
	if (nChannelID == CSupportChannels::SC_CALCBOUNDINGBOX)
	{
		m_pChannelAttrs->m_BoundingBox.Union(m_points.BoundingBox());
	}
	else if (nChannelID == CSupportChannels::SC_DRAWFOREGROUND)
	{
		CRhinoViewport* vp = dp.GetRhinoVP();
		if (nullptr != vp)
		{
			ON_Xform world_to_screen;
			vp->VP().GetXform(ON::world_cs, ON::screen_cs, world_to_screen);
			dp.SetObjectColor(ON_Color(RGB(0, 0, 255)));
			ON_wString str;
			for (int i = 0; i < m_points.Count(); i++)
			{
				str.Format(L"%d", i);
				dp.DrawString(str, world_to_screen * m_points[i], false, 18);
				dp.DrawPoint(m_points[i], 4, RPS_CONTROL_POINT, ON_Color(RGB(0, 0, 255)));
			}
		}
	}
	return true;

3.) CRhinoDoc::AddPointCloudObject return a pointer to a CRhinoPointCloudObject object if successful. By default, points clouds in Rhino draw differently than ‘normal’ point objects. This is all controlled by the display mode properties used by the viewport

Hope this helps.

– Dale

1 Like

@dale
Thank you very much!
Your answer has solved all my problems! :blush:

1 Like