Execute rhino command from plugin


I need to use squish rhino command with a surface and curves selected inside the plugin I’m developing, and then use the squish outputs as surface and curves to continue working with them inside the plugin.

I haven’t found any information about how to interact with rhino commands when creating a plugin, and use their outputs as new objects.

Can anybody help me with this issue?


You can run a script from your plugin. Assuming you use RhinoCommon, you can issue

RhinoApp.RunScript("_-squish <parameters>")

Yo tengo el mismo problema. Me gustaría crear un plugin con phyton y no encuentro información al respecto. Ni siquiera estoy seguro de que pueda hacerlo con phyton. También estoy intentando ejecutar un script con RunPhtyonScript SubcarpetaNombreArchivo sin resultados.

Me gustaría un poco de ayuda para empezar. Muchas Gracias

Thanks for your answer but It doesn’t work, maybe because squish is also a plugin? By the way, I’m using C++.

I’ve already tested your solution (of course with the C++ syntax) as it appears in the examples published in the developers website.

Another issue is that a surface and some curves selected inside my plugin are the parameters for squish command.

And also I need to use the squish output (a new surface and new curves) as objects inside the plugin.

Hope you can help me! Thanks again

Does this help?

I’ve read the example and tried the script  method before asking, but doesn’t seem to work with the squish command. I guess it’s because it’s plugin and  not a native command.

Any other idea?

It shouldn’t matter if the command is implemented in a plug-in or not. Did you make to to have your command class derive from CRhinoScriptCommand instead of CRhinoCommand?

Thanks! Using CRhinoScriptCommand works great! Is there a way to get reference to the output of the command (in this case, the squish command)

I need to use the outuput of the command and continue working with it. Thanks again

Not really. The best you could do is parse the command history window text.

See if this helps:

Thanks @dale now i can point the objects created with the squish command! Thanks

By the way, the output of the squish command includes surfaces, points and curves… i cant find the way to check if these CRhinoObjects are points, curves or surfaces… Is there any example dealing with this issue? Thanks

Do these help?

Hello, i would like to run a zebra analysis from a plug in but i would like to change the seetings of the analysis, but everytime i want to, either rhino crashes or simply just ignore the command. I use the rhinoScriptCommand to run the command from plugin. I use the following code. Srf is the surface I selected previously.

CRhinoZebraAnalysisSettings zebra;

zebra.m_stripe_thickness = 6;

RhinoApp().RunScript( L"_-Zebra ", 0);

Hi @f.leon.marquez95,

The attached seems to work in Rhino 6.

cmdTestLeon.cpp (1.5 KB)

– Dale

Thank you for the code, but if I am working on Rhino5 using visual studio 2010? Because the code gives me errors. Here is the complete code, and specially if i want to change the orientation which is a byte type object.

class CCommandGraph_zebra : public CRhinoScriptCommand
	CCommandGraph_zebra() {}
  ~CCommandGraph_zebra() {}
	UUID CommandUUID()
    static const GUID Graph_zebraCommand_UUID =
    { 0xbd41758b, 0xfa2a, 0x4b99, { 0xb4, 0x1a, 0x8f, 0x14, 0x7b, 0x9c, 0xc4, 0x84 } };
    return Graph_zebraCommand_UUID;
	const wchar_t* EnglishCommandName() { return L"Graph_zebra"; }
	const wchar_t* LocalCommandName() const { return L"Graph_zebra"; }
	CRhinoCommand::result RunCommand( const CRhinoCommandContext& );
static class CCommandGraph_zebra theGraph_zebraCommand;

CRhinoCommand::result CCommandGraph_zebra::RunCommand( const CRhinoCommandContext& context )
  // Select the surface to extract isocurve
	CRhinoGetNumber gN;
	CRhinoGetString gS;
	CRhinoGetObject go;
	go.SetCommandPrompt( L"Select surface" );
	go.SetGeometryFilter( CRhinoGetObject::surface_object );
	go.GetObjects( 1, 1 );
	if( go.CommandResult() != success )
		return go.CommandResult();
	// Validate selection
	const CRhinoObjRef& refSurf = go.Object(0);
	const CRhinoObject* obj_surf = refSurf.Object();
	const ON_Surface* srf = refSurf.Surface();
	if( !srf )
		return failure;
	CRhinoZebraAnalysisSettings settings = RhinoApp().AppSettings().ZebraAnalysisSettings();
  if (settings.m_stripe_thickness != 6)
    settings.m_stripe_thickness = 6;
    settings.m_stripe_direction = 1;

  RhinoApp().RunScript(context.m_doc.RuntimeSerialNumber(), L"_Zebra", 0);

  return CRhinoCommand::success;

	return CRhinoCommand::success;

Hi @f.leon.marquez95,

Try the attached.

cmdTestLeon5.cpp (1.9 KB)

– Dale

Thank you very much Dale, it really helped me a lot.

Hello, is there a way to stop or exit the command run? I mean, I called the zebra analysis but the window of the analysis is still open and i want to exit the command. After the RhinoApp().RunSript(L"_Zebra ", 0); can i add a line code like exit or cancel?

Hi @f.leon.marquez95,

The Zebra command just turns on a display analysis. To turn off the Zebra display analysis, either close the Zebra dialog or run the ZebraOff command.

– Dale