PDA

View Full Version : New feature in max 2010: structs now contain public / private keywords


AlpineMan
04-06-2009, 03:05 PM
One new thing we did for maxscript for max 2010, was to add public / private keywords to scripted struct definitions.
Not only that, but now, private members do not dump their information to the debug output window. This was put in to help security for plugin vendors who write their plugins using maxscript.

See the maxscript docs for more details.

PEN
04-06-2009, 03:34 PM
I didn't know about that, that is excellent. . Is there a public list of changes to Max script anywhere?

LoneRobot
04-06-2009, 03:35 PM
What a great feature chris, I was thinking about this the other day, as I wanted to stop the massive list of functions being printed to the listener every time I opened max. Also helps with usability, only showing the functions you actually need to use! nice work!

AlpineMan
04-06-2009, 03:37 PM
I didn't know about that, that is excellent. . Is there a public list of changes to Max script anywhere?

Not public, but as usual, Bobo puts a lot of effort to document new features in the maxscript docs.

ZeBoxx2
04-07-2009, 12:18 AM
As soon as the demo is available, you can grab that and get the info from the maxscript help file, of course.

Hopefully it's implemented in a backwards-compatible way :)

JHN
04-07-2009, 07:27 AM
Hopefully not, I think, that would mean that in an older version of max you would get access to the struct methods that you don't have access to in a newer version of max. That way you can't use it for encrypting stuff... or am I missing the point....!?

-Johan

spacefrog
04-07-2009, 07:38 AM
as far i understood the help section on this, forwards compatibility is there in that way, that in the past, all structure properties, variables or whatever were public by default.
This is still the case in Max 2010, but now you have the possibility to make them private if you like.
Older Max versions do not understand that tokens (public and private) and would produce errors ,i assume...

ZeBoxx2
04-07-2009, 07:40 AM
not necessarily - depends on how it's implemented. If it's a matter of writing, say:

private someVar type:#etc, then you'll have no choice but to maintain two separate codebases if all you want to do is hide the variable for cleanliness.

If you want it for some manner of copyright protection or somesuch, then backwards compatibility wouldn't be an issue anyway; just don't make a version compatible with anything but 2010 and beyond.. much like you wouldn't write a 3ds Max 8 and below encrypted script if you were serious about hiding your code, given that decrypting that is child's play.

spacefrog
04-07-2009, 07:51 AM
i think public/private is only possible in structures , and is done via a section token, its's not a general variable qualifier as far i can see...

here's an example snippet from the help:

struct foo2
(
public
A = 1,
B = 3,
fn error = throw "ZZZ",

private
C = 77,
fn errorPrivate = throw "ZZZ",
on create do format "in create: %\n" this,
on clone do format "in clone: %\n" this
)
f = foo2() --creating calls the 'on create do()' handler

LoneRobot
04-07-2009, 08:35 AM
Not public, but as usual, Bobo puts a lot of effort to document new features in the maxscript docs.

Does this mean the current docs are private? ;)

AlpineMan
04-07-2009, 01:04 PM
Does this mean the current docs are private? ;)

uh? No. They are part of the installation as usual. I don't know of a public location where someone could download the docs. Though I haven't been looking. THe Autodesk website is pretty big, and I don't really know my way around all of it.

Also, note the new event handlers for when a struct is:
1. created
2. cloned

And for clarification. If a struct doesn't declare any public / private modifiers on it's members, then they are all public by default. Max 2010 of course will still read legacy scripts with legacy structs just fine. But if you take your 'new' script back to old max, yes, it will throw compiler exceptions.

ZeBoxx2
04-07-2009, 01:20 PM
which means you'd have to do something like (wouldn't recommend the temp dir, of course)...

(
local publicFile = createFile "$temp\\public.ms"
local privateFile = createFile "$temp\\private.ms"
if ((maxVersion())[1] / 1000 >= 12) then (
format "public\n" to:publicFile
format "private\n" to:privateFile
)
else ( )
close publicFile
close privateFile
)

Struct test (
include "$temp\\public.ms"
someValue = 1.0,
include "$temp\\private.ms"
anotherValue = 2.0
)

or otherwise keep two separate codebases. Unless there's another solution..

AlpineMan
04-07-2009, 01:36 PM
which means you'd have to do something like (wouldn't recommend the temp dir, of course)...

(
local publicFile = createFile "$temp\\public.ms"
local privateFile = createFile "$temp\\private.ms"
if ((maxVersion())[1] / 1000 >= 12) then (
format "public\n" to:publicFile
format "private\n" to:privateFile
)
else ( )
close publicFile
close privateFile
)

Struct test (
include "$temp\\public.ms"
someValue = 1.0,
include "$temp\\private.ms"
anotherValue = 2.0
)

or otherwise keep two separate codebases. Unless there's another solution..

That looks pretty convoluted. But then if you are desperate, such a thing wouldn't be much of an obstacle, right?. Maxscript has always had language improvements and new features that make new scripts non-backwards compatible. But then again, no one is forcing anybody to use the new functionality. :)

LoneRobot
04-07-2009, 01:48 PM
uh? No. They are part of the installation as usual.

sorry chris, bad pun on my part. :blush: I'll look forward to the UK sub release, this was just what the doctor ordered!

ZeBoxx2
04-07-2009, 02:51 PM
Well you only need to run the first part in whatever script you execute first if you're doing a package of scripts. The include line itself is about as much work as writing 'public' or 'private' 'as is'. It's rather less convoluted than maintaining and distributing two separate sets of scripts.
It's not so much a matter of 'desperation' than of being able to take advantage of new features with as little hassle as possible when considering older platforms.

I'm not too sure how many new features made new scripts necessarily incompatible in other releases; I can only think of $scripts vs $userscripts making -existing- scripts 'unnecessarily' incompatible... and I don't think we had much of a choice but to adapt in that case :)
Other new functionality has been far more of a matter of "if you use this functionality, it won't work in rN and below" and having a script work, display, etc. was a matter of including a max version test, but it would evaluate regardless (until it hits the actual command/structure/etc. being used when run) - whereas this would throw an error upon evaluation ('compilation', if you will), even if the structure may never get used.

In this specific item, a comma might have made all the difference - whether it would have been more or less work on the end of the Max developers is something I wouldn't dream of guessing at.. c/c++, though getting more familiar with it, still makes my brain ache :)

Regardless - it's great new functionality that I definitely see use for; by not exposing those variables/functions of a struct that are only intended for internal use by the struct (or package) itself, rather than the end-user.

PiXeL_MoNKeY
04-07-2009, 04:04 PM
uh? No. They are part of the installation as usual. I don't know of a public location where someone could download the docs. Though I haven't been looking. THe Autodesk website is pretty big, and I don't really know my way around all of it.Look harder next time 3ds Max Product Page > Documentation > 3ds Max 2010 (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12755337&linkID=5604642) Documentation (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12755337&linkID=5604642). Though that may only be the actual Help file and not the maxscript, I know they use to offer all the help and tutorials as downloads.

Edit: Nevermind, that is just the general help. I guess the Maxscript help is only available with the installations.

-Eric

Bobo
04-07-2009, 09:52 PM
Look harder next time 3ds Max Product Page > Documentation > 3ds Max 2010 (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12755337&linkID=5604642) Documentation (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12755337&linkID=5604642). Though that may only be the actual Help file and not the maxscript, I know they use to offer all the help and tutorials as downloads.

Edit: Nevermind, that is just the general help. I guess the Maxscript help is only available with the installations.

-Eric

Well, actually I provided an updated build with some additional fixes after the final drop for the installer and was told it will be posted on the website after the DVDs ship so people can update to the latest and greatest.

So there WILL be a downloadable version, just not yet.

spacefrog
04-08-2009, 06:02 PM
there is a download for the maxscript help now live, together with a download for the SDK help
i have'nt checked if its newer or the than that coming with the max (trial-)install itself

http://usa.autodesk.com/adsk/servlet/item?id=12755414&siteID=123112&linkID=9241175

just checked ... this download is actualy older than the version coming with the trial install (march 4th vs. march 12th) :banghead:

UPDATE:
forget the previous sentence - DL version is NEWER than that one coming with the full install

JHN
04-08-2009, 06:29 PM
Lol, I already have overwritten the old one... lol

But the sdk docs prove to be a interesting read though. Especially the 3dsMaxDotNetSDKRef.chm it lists all dotnet classes available in the SDK and also in mxs. So that gives a neat list of classes and methods that can be called from mxs. Like dotnetClass "CSharpUtilities.ArrayProducer".
It's like sinterklaas (dutch equivalent of SantaClaus but on the 5th of december) with all these new features... Now hopefully CAT will ship anytime soon (or did I miss something) and we can start thinking about deploying...

-Johan

Bobo
04-08-2009, 06:44 PM
The version for the online download was built on March 4th.
It should also have a build data in the title bar as opposed to no date in the shipping version.
The one from March 4th should have more content than the one that comes with the demo/DVD (compare the Documentation Changes... topic).
I don't think I have compiled a newer CHM after that - where did you get the March 12th date from?

JHN
04-08-2009, 06:54 PM
What I like about the mxs docs is you always sneak in some new function in some example like .isHiddenInVpt that makes you read the docs even better, great job!

My mxs helpfile titlebar says (2009/03/04), is that the most up to date? I've offcourse overwritten the old file without thinking twice...

-Johan

Bobo
04-09-2009, 03:55 AM
What I like about the mxs docs is you always sneak in some new function in some example like .isHiddenInVpt that makes you read the docs even better, great job!

My mxs helpfile titlebar says (2009/03/04), is that the most up to date? I've offcourse overwritten the old file without thinking twice...

-Johan

Yes, that file with the date in the titlebar is the most up to date build.

As for .isHiddenInVpt, I don't consider that a sneaky one, I am using it all the time since it covers all possible reasons for an object to be hidden (incl. hidden by category, hidden by layer, frozen with hide frozen objects on or regular node-level hide object flag). Glad you find it useful.

spacefrog
04-09-2009, 07:29 AM
ahh - yep seems i jumped to fast on the conclusion that the DL version is older, since all files in the install packages simply got the installer-build date stamped onto them (which is march 12th)

sorry to cause confusion - the version with the datestring in the title is more recent as bobo said ;-), i corrected my post....

PEN
04-09-2009, 12:07 PM
Well I look forward to using some of these new features, just hope that I can get my clients off Max 2008 so that I can. I had some one ask me a while ago about doing work in Max 3, just laughed, not a chance I'm going back that far.

CGTalk Moderation
04-09-2009, 12:07 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.