PDA

View Full Version : Installing scripts and UI items


Tesctassa
02-01-2008, 08:01 PM
Hi everybody!

I have few questions about scripts in Max. I've been developing several tools (using MaxScript) which should be put all together into a toolbar and a menu. All source files will be encrypted. In few words it's a non-open source scripted plugin (or toolchain to be more precise :))
I was looking for a way to install it and create the UI items during the installation.

I found out about the NSIS (http://www.scriptspot.com/Tutorials/NSIS/Creation%20Application%20Installers%20for%20MaxScripts.htm) tutorial and I've already created a simple installer that copies the files from a location to another, but now I need to create the UI elements.
I know what files Max writes when custom UI elements are added from the "Customize UI" Panel. More specifically it's the "MaxStartUI.cui" file located into the "C:\Documents and Settings\MY_USER\Local settings\Application data\Autodesk\3dsmax\2008 - 32bit\enu\UI".
So I should edit that file using the functions the NSIS script language have, but it's relatively complicated, so I was wondering if there is another way.

The second question is about the script encryption. During the development phase, I simply put the .ms files into the "MAX_ROOT\Scripts\Startup" folder so that Max could load them on startup. The result was that Max generates the .mcr files into the "usermacros" folder placed into its application data folder (as above).
The point is that these tools are part of a toolchain and I want to install them as a third-party plugin.
Alternatively to the first method, I could have put the .mcr files into the "MAX_ROOT\ui\macroscripts" folder and the result wouldn't changed, but I discovered that encrypted .mcr files are not considered by Max during startup, unless they're into the "Startup" folder (with the same results at Max startup).
I wanted to know if it's possible to directly use encrypted .mcr files, that is how the distribution of encrypted scripted plugins works. Even just a reference is good.


Please excuse me if I wasn't clear enoght. Just ask for more details if that's the case.
Thanks for your help!

Regards,
Adriano

JHN
02-01-2008, 08:48 PM
AFAIK, macroscripts cannot be encrypted, you need to filein the .mse in the macroscript.
So you need to split your logic and your interface.

The way I write scripts now almost always get me 3 files.
let's say the tool does pointcache stuff:

pointCacheOps.ms -- Keeps all reusable logic (public functions) in a struct
pointCacheTool.ms -- Keeps all UI data and UI logic (private functions) in a struct
pointCacheMacro.ms -- Has simple code to launch the UI struct

This way I could (if I ever wanted) encrypt the Ops en the Tool file... and use the macro to launch it. Ops en Tool can be installed in stdscripts or startup and macro goes to usermacros, easy management and easy code reuse in other scripts.

Hope this helps...

-Johan

BTW: There's no easy way to add macroscripts to a menu, I'm trying too build a similar tool rightnow to add all my scripts to a menu and make it flexible (some stuff on another active thread, PEN made some code to extract macroscript info... no easy way out here... :( )

Tesctassa
02-01-2008, 10:12 PM
AFAIK, macroscripts cannot be encrypted, you need to filein the .mse in the macroscript.
So you need to split your logic and your interface.

The way I write scripts now almost always get me 3 files.
let's say the tool does pointcache stuff:

pointCacheOps.ms -- Keeps all reusable logic (public functions) in a struct
pointCacheTool.ms -- Keeps all UI data and UI logic (private functions) in a struct
pointCacheMacro.ms -- Has simple code to launch the UI struct

This way I could (if I ever wanted) encrypt the Ops en the Tool file... and use the macro to launch it. Ops en Tool can be installed in stdscripts or startup and macro goes to usermacros, easy management and easy code reuse in other scripts.

Hope this helps...

-Johan
Thanks for the guidelines. Actually I'd already thought of something like that. Most of the interface macro-buttons when opened contains just the code to launch the main function, but I've only found 3DSM internal functions linked in these buttons.
Thanks again for your advices.



BTW: There's no easy way to add macroscripts to a menu, I'm trying too build a similar tool rightnow to add all my scripts to a menu and make it flexible (some stuff on another active thread, PEN made some code to extract macroscript info... no easy way out here... :( )
Thanks for this too. I too found out that there's no easy way here, but I'll try the "file editing" solution. As soon as I should obtain some interesting results , I'll post them. "Quite confident" you might say :P
The point is that I have no choice. I need to find some way to do it (and I will! :D)

Anyway, thanks again!
Regards,
Adriano

Tesctassa
02-04-2008, 05:13 PM
Hi again!

I managed to install a custom UI toolbar for my scripted plugin! But I used an awkward way...
the paths aren't relative yet. :P
Anyway finding them shouldn't be a big trouble. As I wrote in the previous post:
I know what files Max writes when custom UI elements are added from the "Customize UI" Panel. More specifically it's the "MaxStartUI.cui" file located into the "C:\Documents and Settings\MY_USER\Local settings\Application data\Autodesk\3dsmax\2008 - 32bit\enu\UI".
So the "MaxStartUI.cui" file is located into the subfolder "UI" of a Max's system path, manageable from the "Configure System Paths" dialog, "System" tab, under the voice "Max Data".
The problem now is that all the system paths are stored into the "3dsmax.ini" configuration file, which is itself included in the "Max Data" group!!!
In few words "3dsmax.ini" stores the path where it is itself located...

Any idea to retrieve the system paths needed?

I'm gonna try to use a common search and see the results, but I don't how this would work for different version of Max. Also making a simple OS search I found a "3dsmax.ini" file in the Windows\system32 folder.

I'll post any remarkable result :)


Regards,
Adriano

RustyKnight
02-04-2008, 09:15 PM
Ahh, what's wrong with getdir()??? Or are you doing this outside of max??

If you are, check the registery, you might be able to locate path information from there, or you will have to guess at it...

Shane

Tesctassa
02-04-2008, 10:42 PM
Ahh, what's wrong with getdir()??? Or are you doing this outside of max??

If you are, check the registery, you might be able to locate path information from there, or you will have to guess at it...

Shane


Hi Rusty! Yes I'm doing this outside Max. With NSIS, the scriptable installer by Nullsoft. I thought of looking inside the registry, but after reading some Max docs, I'm quite sure that default paths are hardcoded, though I'm still wondering how does 3DSMax recreate the 3dsmax.ini file (if it has been deleted) in the right folder, since the path to that folder is inside that file.... -___-

Any clue??

Regards,
Adriano

RustyKnight
02-04-2008, 11:15 PM
Okay, that makes scense...

I think my approach would be to check well known locations to start with...

ie c:\MaxN, C:\Program Files\Autodesk\3ds Max N, C:\Program Files (x86)\Autodesk\3ds Max N etc. If you can't find it, ask the user...

Basically, I'd be looking for 3dsmax.ini inside these locations.

This will also allow the user to install the script under a number of different installs (we have 8, 9 and are evaluating 2008 at the mo :P)

You might also want to check your findings, as the from max 9, the ini file you're after resides in the user folder under "Local Settings\Application Data\Autodesk\3dsmax\9 - 32bit\enu" (for example)

Shane

Tesctassa
02-05-2008, 12:20 AM
Okay, that makes scense...

I think my approach would be to check well known locations to start with...

ie c:\MaxN, C:\Program Files\Autodesk\3ds Max N, C:\Program Files (x86)\Autodesk\3ds Max N etc. If you can't find it, ask the user...

Basically, I'd be looking for 3dsmax.ini inside these locations.

This will also allow the user to install the script under a number of different installs (we have 8, 9 and are evaluating 2008 at the mo :P)

You might also want to check your findings, as the from max 9, the ini file you're after resides in the user folder under "Local Settings\Application Data\Autodesk\3dsmax\9 - 32bit\enu" (for example)

Shane

Hi again! Thanks for your reply. Just a quick answer 'cause it's 2 in the morning here :P

As you suggested it might be worth to search into "standard" path first, then prompt the user (if he moved the file, then he should know where!). But that could also be a complication for certain users. Besides, I need to check the language of the OS, since system folders varies their name from a localization to another.

To overcome these (maybe not so big) problems, I've decided to split the installation process in two halves. The first will be the regular copy of the files into their destination folders, the second one will be the creation of the UI elements, which will be done from inside Max (probably by a run-once script) at the first launch after the setup.
This way I'll solve all the problems about relative paths and their language once and for all (I just need to find how to address system paths from MaxScript inside 3DSMax 8, but there's the help for that :)).

What do you think about "splitting" the installation?? I didn't see any bad implication so far.

Thanks again!

Regards,
Adriano


ps: plz excuse any syntax error.... I'm nearly asleep :)

RustyKnight
02-05-2008, 12:50 AM
I think that sounds like a good idea

Shane

JHN
02-05-2008, 07:37 AM
I'd go for that too... I'm doing something similar right now, without the installer (network drive filein's).

-Johan

Tesctassa
02-05-2008, 08:30 PM
Hi all! Quick update...

Maybe it's a newby error, but it's impossible to modify the "MaxStartUI.cui" file when Max is opened. I'm referring to the two-phase installation:
To overcome these (maybe not so big) problems, I've decided to split the installation process in two halves. The first will be the regular copy of the files into their destination folders, the second one will be the creation of the UI elements, which will be done from inside Max (probably by a run-once script) at the first launch after the setup.
Well the reason why this isn't possible is that Max write the "MaxStartUI.cui" file on shutdown hence losing all modification done during the second phase of the installation.

So here the problem comes again. From an external application I need to retrieve those files, "MaxStartUI.cui" and "MaxBackupUI.cui". I'll try some of the solutions mentioned above, but if someone feels like giving any advice, he's welcome! :)

Regards,
Adriano

Tesctassa
02-06-2008, 04:26 PM
Hi all! Quick update...

Maybe it's a newby error, but it's impossible to modify the "MaxStartUI.cui" file when Max is opened. I'm referring to the two-phase installation:

Well the reason why this isn't possible is that Max write the "MaxStartUI.cui" file on shutdown hence losing all modification done during the second phase of the installation.

So here the problem comes again. From an external application I need to retrieve those files, "MaxStartUI.cui" and "MaxBackupUI.cui". I'll try some of the solutions mentioned above, but if someone feels like giving any advice, he's welcome! :)

Regards,
Adriano

I DID IT!!! I take my words back! It's possible to modify the "MaxStartUI.cui" file. The way is to register a callback function for the event
#postSystemShutdownDoing this, Max will update the file first, then will call this function.

I followed this procedure:

- at Max startup my installation script registers the callback
- then copies the UI file into a temp file (MaxStartUI_TEMP.cui)
- when user shuts down Max the script renames the two files like this: MaxStartUI.cui -> MaxStartUI.cui.bkp
MaxStartUI_TEMP.cui -> MaxStartUI.cui

And the work is done! At next startup, the custom UI elements are present!

Thanks to all for your help!
Regards,
Adriano
:)

CGTalk Moderation
02-06-2008, 04:26 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.