In my C++ SDK plugin, the “Line” command with “0,0,0 10,10,0” as start/end coordinates parameters is called. The problem is that my plugin always skips parameters after “-_Line”, as depicted in the screen capture below. I tested RhinoApp().RunScriptEx(doc_sn, L"-_Line 0,0,0 10,10,0", nullptr), RhinoApp().RunScript(doc_sn, L"-_Line 0,0,0 10,10,0"), RhinoApp().RunMenuScript(L"-_Line 0,0,0 10,10,0"), without any improvements.
Here follows my C++ code:
CRhinoCommand::result CCommandMakeLine_10::RunCommand(const CRhinoCommandContext& context)
{
// CCommandMakeLine_10::RunCommand() is called when the user
// runs the "MakeLine_10".
unsigned int doc_sn = context.Document()->RuntimeSerialNumber();
RhinoApp().RunScriptEx(doc_sn, L"-_Line 0,0,0 10,10,0", nullptr);
context.Document()->Redraw();
return CRhinoCommand::success;
}
My command is a C++ plugin. It inherits from CRhinoUtilityPlugin.
It has been constructed using the Rhino SDK. In Visual Studio 2022: Menu File > New Project > Rhino 3D Plugin (C++ ) “Build plug-ins for Rhino using the C++ SDK”.
Here follows the header:
// MakeLine_10PlugIn.h : main header file for the MakeLine_10 plug-in.
//
#pragma once
// CMakeLine_10PlugIn
// See MakeLine_10PlugIn.cpp for the implementation of this class
//
class CMakeLine_10PlugIn : public CRhinoUtilityPlugIn
{
public:
// CMakeLine_10PlugIn constructor. The constructor is called when the
// plug-in is loaded and "thePlugIn" is constructed. Once the plug-in
// is loaded, CMakeLine_10PlugIn::OnLoadPlugIn() is called. The
// constructor should be simple and solid. Do anything that might fail in
// CMakeLine_10PlugIn::OnLoadPlugIn().
CMakeLine_10PlugIn();
// CMakeLine_10PlugIn destructor. The destructor is called to destroy
// "thePlugIn" when the plug-in is unloaded. Immediately before the
// DLL is unloaded, CMakeLine_10PlugIn::OnUnloadPlugin() is called. Do
// not do too much here. Be sure to clean up any memory you have allocated
// with onmalloc(), onrealloc(), oncalloc(), or onstrdup().
~CMakeLine_10PlugIn() = default;
// Required overrides
// Plug-in name display string. This name is displayed by Rhino when
// loading the plug-in, in the plug-in help menu, and in the Rhino
// interface for managing plug-ins.
const wchar_t* PlugInName() const override;
// Plug-in version display string. This name is displayed by Rhino
// when loading the plug-in and in the Rhino interface for
// managing plug-ins.
const wchar_t* PlugInVersion() const override;
// Plug-in unique identifier. The identifier is used by Rhino for
// managing plug-ins.
GUID PlugInID() const override;
// Additional overrides
// Called after the plug-in is loaded and the constructor has been
// run. This is a good place to perform any significant initialization,
// license checking, and so on. This function must return TRUE for
// the plug-in to continue to load.
BOOL OnLoadPlugIn() override;
// Called one time when plug-in is about to be unloaded. By this time,
// Rhino's mainframe window has been destroyed, and some of the SDK
// managers have been deleted. There is also no active document or active
// view at this time. Thus, you should only be manipulating your own objects.
// or tools here.
void OnUnloadPlugIn() override;
private:
ON_wString m_plugin_version;
// TODO: Add additional class information here
};
// Return a reference to the one and only CMakeLine_10PlugIn object
CMakeLine_10PlugIn& MakeLine_10PlugIn();
That all looks good, but you also have a command of which you showed the implementation earlier, and what I meant was the inheritance of that CCommandMakeLine_10 command.
You should have something like this:
class CCommandMakeLine_10 : CRhinoScriptCommand // <-- inherit from CRhinoScriptCommand, not CRhinoCommand
{
// command declaration and definition comes here
};