CGTalk > Software > Autodesk 3ds max
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-16-2013, 12:04 PM   #1
KingMax02
Veteran
portfolio
iSport
TA
XPEC
SuZhou, Taiwan
 
Join Date: Jun 2006
Posts: 50
Send a message via ICQ to KingMax02 Send a message via MSN to KingMax02
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-17-2013, 03:51 AM   #2
KingMax02
Veteran
portfolio
iSport
TA
XPEC
SuZhou, Taiwan
 
Join Date: Jun 2006
Posts: 50
Send a message via ICQ to KingMax02 Send a message via MSN to KingMax02
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-17-2013, 03:51 AM   #3
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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 12:06 PM.


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