This section describes how to create a Workspace and Toolbars using Rhino 6.
-
Create a separate workspace called
Flows
fromTools > Options > Toolbars
-
Next step is to add a new toolbar called
Sample Flow
as shown below
Note: Our goal is to connect the Sample Flow
toolbar with a plugin of the same name.
- Then several buttons are added to the
Sample Flow
toolbar. Here each button represents a particular step in the flow.
For a detailed description on how to create macros for toolbars go here.
Note: The goal is to connect each step in the Sample Flow
toolbar with a command in the plugin with the same name.
-
Open up the Flows folder in Visual Studio 2017.
-
Create new project in Visual Studio 2017
File > New > Project
-
Open the
SampleFlow.sln
file fromFlows/
folder and rename the solution toFlows
-
Go to the auto generated SampleFlow Visual C++ project and in the
stdafx.h
file, uncomment line 19#define RHINO_SDK_MFC
. We need to uncomment this line as we would be using the MFC UI functionality.Note: Rhino 6 is almost MFC free except for the RhinoUI library which requires MFC as the Rhino Application is based on MFC
-
Go to file
SampleFlowPlugIn.cpp
and comment the line 46 so that the plugin compiles. Note that in general delete this line after filling in the appropriate information asked for. -
In Visual Studio 2017 go to
Project > Properties
and then inC/C++ > Language
change theC++ Language Standard
toISO C++14Standard (/std:c++14)
and apply
Followed by build, this should compile the SampleFlow
Rhino plugin project successfully.
-
In the next step go to the
Flows.rui
workspace and open theWorkspace Editor
and go to theMenus
, then add the Menu and Menu-Item. -
To connect the menu item
Sample Flow
to the plugin we use theWorkspace Editor
in Rhino to create the corresponding C++ code.
- Then transfer the code to the SampleFlow plugin project into the following files :
FlowsRuiOnUpdateMenuItems.h, FlowsRuiOnUpdateMenuItems.cpp
#include "stdafx.h"
#include "FlowsRuiOnUpdateMenuItems.h"
#include "SampleFlowPlugIn.h"
CFlowsRuiOnUpdateMenuItems::CFlowsRuiOnUpdateMenuItems()
{
// Register OnUpdateMenuItem callback for this item
RegisterMenuItem(CSampleFlowPlugIn::m_idFile, CSampleFlowPlugIn::m_idMenuFlows, CSampleFlowPlugIn::m_idMenuItemSampleFlow);
}
void CFlowsRuiOnUpdateMenuItems::OnUpdateMenuItem(CRuiUpdateUi& cmdui)
{
// Enable menu item
if (CSampleFlowPlugIn::m_idMenuItemSampleFlow == cmdui.MenuItemUUID())
{
cmdui.Enable(true);
}
}
and the following static const
variables are added to SampleFlowPlugIn.cpp
const UUID CSampleFlowPlugIn::m_idFile = { 0x6fbd18ca, 0xbdce, 0x44ae, { 0xba, 0x8f, 0x3c, 0x2c, 0x46, 0x3e, 0x52, 0xf9 } };
const UUID CSampleFlowPlugIn::m_idMenuFlows = { 0x130a9a5b, 0x5620, 0x4588, { 0x96, 0x41, 0x13, 0xd6, 0x7d, 0x4a, 0x19, 0x07 } };
const UUID CSampleFlowPlugIn::m_idMenuItemSampleFlow = { 0x7648b550, 0xb008, 0x42ab, { 0xb2, 0xb3, 0xf1, 0xb8, 0xf4, 0xac, 0xe5, 0x97 } };
Now we would like to connect the Menu-item Sample Flow
with the corresponding Sample Flow
toolbar.
- First we open the
Workspace Editor
for theFlows.rui
and then gotoMenus
. - Click on
Flows > Sample Flow > Item Properties
-
After this in the
Command
section ofItem Properties
forSample Flow
call the correct commands such that the Toolbar pops up.
TODO
The next step would be to connect the Simple Flow
toolbar with the plugin with the same name.
Create and Deploy Toolbars
In this section we will describe the steps to programmatically connect Start Flow
button in the Sample Flow
Toolbar to the Sample Flow
plugin in Rhino. The design is based on the Command pattern.
-
For the
Start Flow
button we create a corresponding commandcmdStartFlow.cpp
in theFlows.sln
. -
For the
Start Flow
button we create a new Viewport for ourSample Flow
plugin. This is done by using the Command Pattern and creating a separate class calledCSampleFlowViewReceiver
such that from the classCCommandStartFlow
we invoke theaction
method on aCSampleFlowViewReceiver
object. -
The next step then is to connect the
Start Flow
command in theSample Flow
plugin to theStart Flow
button