PDA

View Full Version : Checking for dotNET types, and associative arrays


ofer_z
03-18-2007, 11:06 PM
Hi,

Does anyone know if it's possible to check the type of a dotNET object?

print o
dotNetObject:System.DateTime

classOf o
dotNetObject

superClassOf o
Value

dotNET.getType o
dotNetObject:System.RuntimeType[System.DateTime]




None of the above returns a maxscript object (obviously). So, is there a way to check if a dotNET is of a specific dotNET class (other than comparing strings)?



Another question: did anyone find a way of creating associative arrays in maxscript?

There is the struct way:



struct s_AssociativeArray (
names = #(),
values = #(),
fn add n v=
(
if not isKindOf n name then
n = (n as string) as name
append names n
append values v
),
fn get n =
(
if isKindOf n integer then (
i = n
) else (
if not isKindOf n name then
n = (n as string) as name
local i = findItem names n
)
if i > 0 then
values[i]
else
undefined
)
) -- end of s_AssociativeArray struct





But it's not as elegant as real associative arrays.



Thanks,

o

CGTalk Moderation
03-18-2007, 11:06 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.