dotnetobject

In 3ds Max 9 and higher, the dotNetObject value class wraps instances of DotNet objects. It is the MAXScript wrapper class around a DotNet System::Object object.

The dotNetObject class exposes the properties, methods, and events associated with the object via reflection.

Property access uses MAXScript number data types (widened as necessary), String, Boolean, dotNetControl, dotNetObject, and dotNetClass values.

Properties of dotNetObject can be accessed via the normal property access specification [object.property] and the getProperty() / setProperty() methods.

Accessing an object method will create a dotNetMethod instance.

New methods are used to add and manage event handlers. These methods register and unregister callback functions to be called when the event is fired. The arguments passed back to the functions include the object, the event name, and the arguments passed by the event handler. See dotNet Struct Methods for details.

NOTE:

There is a difference between a dotNetClass and a dotNetObject that wraps the same type.

Accessing the dotNetClass accesses the System::Type while accessing the dotNetObject accesses the object type described by the System::Type.

So, for example, if you called showProperties() on a dotNetObject you will get the properties of the System::Type the dotNetObject wraps, but on a dotNetClass that wraps the same type you will get the properties of System::Type itself.

   

Constructor:

dotNetObject { <dotNetClass> | <class_type_string> } ... additional args as needed ... 	 

Constructs a dotNetObject object.

A dotNetObject can be created either using the class type string or from a dotNetClass:

EXAMPLE

o1 = dotNetObject "System.Drawing.Size" 10 20 -- existing object
o2 = dotNetClass "System.Drawing.Size"
o3 = dotNetObject o2 10 20 -- newobject from class 

   

Operators:

== != 

   

Methods:

getProperty <dotNetObject> <prop name> [  asDotNetObject:<bool>] 

Returns the value of the specified property.

If asDotNetObject is false (the default) the value will converted to a native MAXScript value if possible; if true, the value will always be returned as a dotNetControl or dotNetObject value.

   

setProperty <dotNetObject> <prop name> <value> 

Sets the value of the specified property. If the value specified is a native MAXScript value, it will be converted to the proper DotNet value if possible.

   

getPropNames <dotNetObject> [showStaticOnly:<bool>] [declaredOnTypeOnly:<bool>] 

Returns an array of property names exposed by the object.

If showStaticOnly is true (the default), only static properties are shown; if false both static and instance properties are shown.

If declaredOnTypeOnly is true, only properties declared on the specified object are shown; if false (the default) properties on the object and the classes it derives from are shown.

The results of this method are sorted by name. The properties returned actually contain two different things in terms of DotNet - properties and fields. The properties are shown first in sorted order, then the fields are shown in sorted order.

   

showProperties <dotNetObject> ["prop_pat"] [to:<stream>] [showStaticOnly:<bool>] [showMethods:<bool>] [showAttributes:<bool>] [declaredOnTypeOnly:<bool>] 

Displays the properties exposed by the object whose name matches the property pattern.

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

If showStaticOnly is true (the default), only static properties are shown; if false both static and instance properties are shown.

If showMethods is true, the signature of the get and set methods (if any) are shown; defaults to false.

If showAttributes is true, the attributes associated with the property are shown; defaults to false.

If declaredOnTypeOnly is true, only properties declared on the specified object are shown; if false (the default) properties on the object and the classes it derives from are shown.

The results of this method are sorted by name. The properties returned actually contain two different things in terms of DotNet- properties and fields. The properties are shown first in sorted order, then the fields are shown in sorted order.

   

showMethods <dotNetObject> ["prop_pat"] [to:<stream>] [showStaticOnly:<bool>] [showSpecial:<bool>] [showAttributes:<bool>] [declaredOnTypeOnly:<bool>] 

Displays the methods exposed by the object whose name matches the property pattern.

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

If showStaticOnly is true (the default), only static properties are shown; if false both static and instance properties are shown.

If showSpecial is true, methods that are not normally called by the user (such as a method to set a property value or to invoke an event handler) are shown; defaults to false.

If showAttributes is true, the attributes associated with the property are shown; defaults to false.

If declaredOnTypeOnly is true, only properties declared on the specified object are shown; if false (the default) properties on the object and the classes it derives from are shown.

The results are sorted by name. Secondary sort is performed based on the number of parameters.

   

showEvents <dotNetObject> ["prop_pat"] [to:<stream>] [showStaticOnly:<bool>] [declaredOnTypeOnly:<bool>] 

Displays the events exposed by the object whose name matches the property pattern.

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

If showStaticOnly is true (the default), only static properties are shown; if false both static and instance properties are shown.

If declaredOnTypeOnly is true, only properties declared on the specified object are shown; if false (the default) properties on the object and the classes it derives from are shown.

The results are sorted by name.

   

dotNet.showConstructors <dotNetClass> [to:<stream>] 

Displays the constructors exposed by the object.

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

The results are sorted by name. Secondary sort is performed based on the number of parameters.

See Also