use Dictionary question

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2013   #1
use Dictionary question

Hey, I write a script tool in max2012, it's work good, but not work in max9,
the problem is due to dotNetObject Dictionary.
there are some code:

------------------------------
struct xNode
(
nodeName,
fn Log =
(
print nodeName
)
)
myNode = xNode "myNodeName"
dt = dotNetObject "System.Collections.Generic.Dictionary`2[System.String, System.Object]"
dt.Add myNode.nodeName (dotNetMXSValue myNode)
------------------------------

in max9, the error show:
-- Runtime error: No method found which matched argument list

in max2012, No error!

In this case, how to wrap the MS struct object into System.Object?
Perhaps there are other ways?

Thank you for advice.
__________________
mailTo:kingmax.res@gmail.com
 
Old 06 June 2013   #2
I think the best way is implement own dict:

--My Dictionary
struct dict
(
keys = #(),
values = #(),

--methods:
fn Count =
(
if keys.count == values.count then
(
keys.count
)
else
(
print "Error: keys.count != values.count"
0
)
),

fn Add key value =
(
if findItem keys key == 0 then
(
append keys key
append values value
true
)
else
(
print ("key has already been added! -->" + key)
false
)
),

fn Clear =
(
keys = #()
values = #()
true
),

fn Remove key =
(
index = findItem keys key
if index != 0 then
(
deleteItem keys index
deleteItem values index
true
)
else
(
print ("cann't find the key! -->" + key)
false
)
),

fn GetItem key =
(
index = findItem keys key
if index != 0 then
(
if keys.count == values.count then
(
values[index]
)
else
(
print "Error: keys.count != values.count"
undefined
)
)
else
(
print ("cann't find the key! -->" + key)
undefined
)
)
)
__________________
mailTo:kingmax.res@gmail.com
 
Old 06 June 2013   #3
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:21 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.