CRhinoSdkUiFile.h and CRhinoUiFile class clarifications

Dear all,

i’m currently trying to update my old v4 toolbar stuff to the recent V5 by using as found somewhere on the internet the CRhinoSdkUiFile.h static methods.

The basic code looks similar to this one below:

m_ToolbarFileName = ON_wString(L"path to the .rui file");

if (CRhinoUiFile::FileIsOpen(m_ToolbarFileName, true))
m_ToolbarFileUUID = CRhinoUiFile::FileID(m_ToolbarFileName, true);
else m_ToolbarFileUUID = CRhinoUiFile::FileOpen(m_ToolbarFileName);

m_GroupUUID = CRhinoUiFile::GroupID(m_ToolbarFileUUID, 0); if
(!CRhinoUiFile::GroupIsVisible(m_ToolbarFileUUID, m_GroupUUID)) {
bool res = CRhinoUiFile::GroupShow(m_ToolbarFileUUID, m_GroupUUID,
true); if (res)
DEBUGMSG(L"GroupShow returned true"); else
DEBUGMSG(L"GroupShow returned false"); } else DEBUGMSG(L"Toolbar group already visible");

Two questions:

FileIsOpen() method always returns false although after Rhino completes loading it reports that the pointed .rui file is already loaded (nowhere else in my code i invoke FileOpen() )
GroupShow() when run at the Rhino startup, if the toolbar is not visible, always return false as it doesn’t succeed in showing the toolbar
Is there any hints or simple example explaining the CRhinoUiFile class?

Thanks in advance for supporting

@JohnM can you help here?


I wrote a simple function that will open a RUI file and show a specific group from that file by name to help demonstrate how this works. Click here to see the code.

The CRhinoUiFile::FileIsOpen() method was always returning false because you where passing true as the second argument indicating that the name string is a file alias and not a file name, when passing a file name always use false.

The above code formatting is a bug in the forum software that we are running. This has been reported as fixed and should clean itself up in our next server upgrade. @JohnM it is probably best for now to create a github gist and post a link to it here.

Thanks John, going to apply changes. I’ll let you know.

Regards, Ric

PS: the FileIsOpen method returned false whatever the second argument. Maybe the FileIsOpen method returns properly only after Rhino has been properly loaded and not during the “launching” phase?