Create own toolbar with programming

mustafapassahci
Contributor
Contributor

Create own toolbar with programming

mustafapassahci
Contributor
Contributor

I created my own script using PySide2 and now I am writing another "program" in Python to create my own toolbar -> add my macroscripts to the toolbar and show it on the screen finally (like VRay does).

 

I want to use my macroscripts on so many computers that if I did so one by one manually, it would take too much time. I mean, I don't want to open 3ds max -> Customize -> Customize User Interface -> add new tool bar -> add my scripts there etc. for all computers.

 

I came up with this solution in the end:

1- add my own macroscripts to ..\Autodesk\3dsMax\2022 - 64bit\ENU\usermacros

2- open ..\Autodesk\3dsMax\2022 - 64bit\ENU\en-US\UI\Workspaces\usersave\Workspace1__usersave__.cuix file and add this code:

 

 

<Window objectName="new_tool_bar" name="new_tool_bar" type="T" cType="1" toolbarRows="1">
            <Items>
                <Item typeID="2" type="CTB_MACROBUTTON" width="52" height="0" controlID="0" macroTypeID="3" macroType="MB_TYPE_ACTION" actionTableID="647394" imageID="-1" imageName="" actionID="MacroScriptName`Category" tip="mymacroscript" label="mymacroscript" />
            </Items>
</Window>

 

 

3- and when I start 3ds Max, my toolbar will be there.

 

but this is absolutely not a good way of doing it for example: if 3ds max was already open and I close it, Workspace1__usersave__.cuix would be overwritten, there are also a lot of language files etc.

 

I want to create my own toolbar automatically when my program is run by the user. When I open/restart 3ds max I want to see this without having to do anything manually.

unknown

what should I do?

 

0 Likes
Reply
Accepted solutions (1)
2,277 Views
9 Replies
Replies (9)

tagopinath
Enthusiast
Enthusiast

Hello,

 

I can suggest one method, see if this can work for you.

 

After adding your toolbar and buttons (manually by drag and drop), save this  (overwrite the default cuix file).

Give this file along with your plugin or application to the users.

Create a small application, which will copy this file and paste to en-US\...... folder, after copying, the same application should start 3dsmax.exe (using shellexecute)

Insist your users to start from this small application exe instead of 3dsmax.exe

 

Regards,

Gopinath.

0 Likes

Serejah
Advocate
Advocate


@mustafapassahci  написал (-а):

I want to create my own toolbar automatically when my program is run by the user. When I open/restart 3ds max I want to see this without having to do anything manually.

what should I do?

 

You have no other options except to use c++ to make it programmatically. Example is available in sdk: maxsdk\howto\ui\cuitest\cuitest.cpp

 

 

Unfortunately none of the methods to make a toolbar aren't exposed to maxscript or .net. The only workaround I can think of is to emulate user actions i.e. open dialog, press a button, input a toolbar name, press ok. Then you can grab a toolbar using .net GetICustToolbar and add all needed macro

 

 


0 Likes

mustafapassahci
Contributor
Contributor

Wouldn't doing this break the user's existing layout? I think this is not a safe way to doing this.

0 Likes

mustafapassahci
Contributor
Contributor

I am going to take a look at the documentation, thank you but "d5 render" actually doing this with python (I can't see their codes because they encrypted (as expected)

0 Likes

Serejah
Advocate
Advocate

@mustafapassahci  написал (-а):

... actually doing this with python (I can't see their codes because they encrypted (as expected)


There's a python example for MaxPlus in the reference called demoPySideToolBarQWidget.py, but since MaxPlus is deprecated I don't know if you could make something of it. Not really sure if it is a true toolbar that supports drag-drop user macro. Never messed up with python

denisT.MaxDoctor
Advisor
Advisor

@Serejah wrote:


 

You have no other options except to use c++ to make it programmatically. Example is available in sdk: maxsdk\howto\ui\cuitest\cuitest.cpp



I don't think this C++ method no longer works for MAX 2020+. I'm assuming the new Qt mechanics are being used for new versions.

mustafapassahci
Contributor
Contributor
Accepted solution

Sorry, I am a little confused. Qt mechanics also uses C++ methods, isn't it? Or you meant, just those types of C++ methods no longer works?
And I am sure, I downloaded Max SDK 2022 then why those methods are still there even though no longer works, do you know?

------

if Max using Qt mechanics for 2020+, that mean I can create tool bar using PySide2, right?

+++ and after a little research, it seems I really can! there is an example.

 

so my next steps should be something like this I guess: I am gonna create a max script in startup folder that runs my python script. And it will check my tool bar is exists or not, if not exists then I am going to create a new tool bar etc.

 

I am not sure though.

0 Likes

denisT.MaxDoctor
Advisor
Advisor

@mustafapassahci wrote:

it seems I really can! there is an example.

 


This is the right direction (IMHO). In the MAX 2020+ versions, the mechanics of "docking" has been changed from native WINAPI based to Qt.

Of course, both are in c++, but they are implemented differently.

Serejah
Advocate
Advocate
The only problem I see in these pyhon "toolbars" is that they use a lot of space when docked and at the same time don't support user customization (drag-drop user macro etc..)