dotNet Struct Methods

new.gif NEW in 3ds Max 9: The dotNet Struct provides additional MAXScript methods for managing dotNet objects, classes, assemblies, event handlers etc.

 

<dotNetObject>dotNet.loadAssembly <assembly>

This method loads the specified assembly. The assembly can be specified as an assembly name or the filename of the dll containing the assembly.

The method first attempts to load an assembly from the application directory or from the global assembly cache using the assembly name. If that fails, a dll with the assembly name is searched for in the directory containing the primary .net assemblies.

If the assembly is found and successfully loaded, a dotNetObject value wrapping the .net assembly value is returned, otherwise a value of undefined is returned.

 

Examples:

dotnet.loadAssembly "system.xml"

dotnet.loadAssembly "system.xml.dll"

dotnet.loadAssembly "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\system.xml.dll"

dotnet.loadAssembly "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\system.xml"

 

 

dotNet.addEventHandler()

This method adds an event handler to a dotNetControl.

If two arguments are specified for dotNetControl event handlers, the first argument should contain the sender, the second the eventArg.

If the event handler doesn't specify any argsuments, none are passed.

If the event handler specifies one argument, then the eventArg is passed.

Note:

You can register multiple functions with differing number of argsuments for the same event using dotNet.addEventHandler().

dotNet.removeAllEventHandlers()

Removes all event handlers from the specified dotNetControl.

dotNet.removeEventHandler()

Removes the specified event handlers from the given dotNetControl.

dotNet.removeEventHandlers()

Removes the specified event handlers from the given dotNetControl.

 

dotNet.showConstructors [<dotNetClass> | <dotNetObject> | <dotNetControl>] [to:<stream>]

Displays the constructors exposed by the specified DotNetClass, DotNetObject or DotNetControl.

If to is not specified, the output goes to Listerner, otherwise the output goes to the specified stream.

dotNet.getType <type_string>

Returns a dotNetObject value that wraps the System:Type specified by the type string.

 

dotnet.combineEnums {<dotNetObject> | <number>}+

Combines System::Enum-derived objects that are to be treated as bit fields (these have a FlagsAttribute attribute). The System::Enum-derived objects must all be of the same type. The return value is of that type. If a number is specified, at least one System::Enum-derived object must also be specified (to provide the type).

dotnet.CompareEnums {<dotNetObject> | <number>} {<dotNetObject> | <number>}

Performs bit-wise comparison of the two value. Returns true if at least one corresponding bit is set in each value.

Example:

BindingFlags= dotNetClass "System.Reflection.BindingFlags"

dotNetClass:System.Reflection.BindingFlags

 

BindingFlags.Static.value__

8

 

BindingFlags.Public.value__

16

 

BindingFlags.FlattenHierarchy.value__

64

 

res = dotNet.combineEnums BindingFlags.Static BindingFlags.Public 2 dotNetObject:System.Reflection.BindingFlags

 

res.value__

26

 

dotNet.compareEnums res 1

false

dotNet.compareEnums res BindingFlags.Static

true

dotNet.compareEnums res BindingFlags.Public

true

dotNet.compareEnums res BindingFlags.FlattenHierarchy

false

 

 

See also

DotNet In MAXScript