Rhino8, WindowLayout

undefined
In Rhino7, I was able to change the ui through the rui file.
So I changed the UI as shown above.

But in Rhino8, I need to change the ui through windowLayout.

Is there a way to change the .rhw file using RhinoCommonAPI like rhino7?
RhinoApp.RunScript("-WindowLayout") can’t import .rhw file.


In the picture above, the red arrow is pointing to what I want to do in C# code. (Import .rhw File)

Enviroment: C#, RhinoCommon - Plugin

2 Likes

I believe you could solve your problem by creating a SKIN.dll, and then Export the Window Layout and save it with the same name as the SKIN.dll but with the .rhw file extension. Then when Rhino loads your skin, it will automatically apply your layout.

Here a link to a comment related to this that helped us solve a layout issue with our plugin:

Are you talking about how to swap the default Skin.dll that Rhino has with your customized skin.dll?

For Skin.dll, I know it is supported in c/c++. Is it possible to apply skin.dll using only code in C# environment?

No, I’m talking about launching Rhino with a /scheme switch. The scheme reads the registry to get a path to a skin.dll.

The Skin.dll is used to override the default Name and other options of Rhino.

Once you have created your own skin projet in c# you can also export a Window Layout to an rhe file.

The Skin when loaded will automatically apply the matching named Window Layout file.

Read the item I linked above for more info.

I’m really sorry but it’s too hard for me to apply to skin.dll.

Can you tell me in detail how to use /scheme after generating skin.dll?

Here is an excerpt from our Skin.dll that we use for JewelBeetle.

The important method for us is the OnBeginLoadAtStartPlugIns() in here we load your main rhino plugin which starts up our application.

Because we name output of the skin project: JewelBeetle.Skin.dll
image

We then only need to have a saved Window Layout file names JewelBeetle.Skin.rhw in the same directory that the skin.dll is, and Rhino will automatically load it on startup and apply the window layout.

We do this instead of messing with loading Toolbars and Hiding UI Panels, etc. Instead we just setup everything the way we want it to be and the export the *.rhw file:

So in our case we name our layout JewelBeetle.Skin.rhw and include it in the folder we ship our software in, along side the plugin, and the JewelBeetle.Skin.dll file.

Once you’ve ran Rhino one time with the /scheme=YourPluginScheme name, it will create a registry entry here (or in Rhino 7 if that is your case):

Then you just need to add the SkinDLLPath key pointing to where your skin.dll file is.

From that point on, anytime you launch Rhino with your scheme name, it will load your skin.dll, which will load your plugin, and it will then load/apply your window layout.

Hope this helps, it took me a while to figure it out, but I think it is the best way to do this…

Once you get it all working well, you can create a very custom looking application making use of Rhino at it’s core:

2 Likes

Oh !!!

Thx… I did it !

Sorry, I have one more question.

I want to package and distribute the skin.dll, Plugin-file, and .rhw file that I created.

Does the user who receives the distribution also need to set the scheme of Rhino.exe?

Is there a way to automate the scheme setting with something like a batch file?

You could create a batch file, but you will need to determine the install path of Rhino.

I will look at writing you a batch file in the morning when I’m back in the office.

Here is a batch file which will search the registry for the install location of Rhino, first looking for Rhino 8, and if not found, look for Rhino 7.

It will then launch Rhino with a Scheme and Framework switch. You can modify this as you need.

If your plugin is compiled for .Net 4.8 you can supply the /netfx switch, if it is compile for .Net Core then supply the /netcore switch.

Replace the MySchemeName with your scheme that you used to generate the registry section containing your skinDLLPath above. Scheme names are case-sensitive.

@echo off
REM Batch script to find and start Rhino executable from registry

REM First registry path (Rhino 8.0)
set "RegistryPath1=HKLM\SOFTWARE\McNeel\Rhinoceros\8.0\Install"

REM Second registry path (Rhino 7.0)
set "RegistryPath2=HKLM\SOFTWARE\McNeel\Rhinoceros\7.0\Install"

REM The value name to find in the registry
set "ValueName=ExePath"
set "ExePath="

REM Function to query the registry and get the exe path, handling spaces in path
for /f "tokens=2,*" %%A in ('reg query "%RegistryPath1%" /v "%ValueName%" 2^>nul') do (
    set "ExePath=%%B"
)

REM If Rhino 8.0 is not found, check Rhino 7.0
if not defined ExePath (
    for /f "tokens=2,*" %%A in ('reg query "%RegistryPath2%" /v "%ValueName%" 2^>nul') do (
        set "ExePath=%%B"
    )
)

REM If ExePath is still not defined, Rhino was not found
if not defined ExePath (
    echo Rhino Not Found
) else (
    REM Launch the Rhino executable, using quotes around the path to handle spaces
    echo Rhino found at: "%ExePath%"
    start "" "%ExePath%" /scheme=MySchemeName /netfx
)

pause

Hope this helps you get where you need to go. Let me know if you have questions.

Jason

2 Likes

The method you mentioned is really useful. Thanks.

It looks like you are running Rhino via the batch file written above. Is that right?

Instead of running Rhino via the batch file, can you set /scheme=MySchemeName as a normal Rhino launch option via the batch file?

I don’t understand your question, you asked if a batch file could be used to launch Rhino with a scheme, that is exactly what the batch file I wrote for you does.

Did you read my post above explaining how to change the scheme to match your situation?

This file once you edit it, could be shipped with your plugin.

You will still need to have a registry file to update the skindllparh for your scheme.