Currently the objects being referenced in things such as IINode are the wrapper objects. For example IINode.ObjectRef. Is it possible to make these things hold their .net interface counterparts? |
| Hi Kyle, Not entirely sure what you mean. You can extract/assign interfaces to any of those members.. in fact you shouldn't be concerned (or need to know) about wrappers at all. It is perfectly legal to do something like: IObject myObject = ...; IINode myNode = ...; myNode.ObjectRef = myObject; Same goes for all functions and properties. Marsel Marsel Khadiyev (Software Developer, EPHERE Inc.) |
| If you get an INode from a geomobject for example or any other built in type. You can cast to whatever interface is appropriate, but the objects actual type is from wrappers. This makes it difficult to do reflective operations. |
| What kind of reflective operations do you have in mind? Yes the wrapper is the underlying type, however, Max.NET is designed for working with interfaces, not wrappers. The usual workflow, for example, to check if an object is of certain type is: IObject obj = node.ObjectRef; if( obj is IGeomObject ) { ( obj as IGeomObject ).propertyName... } Likewise, if you have only type and not an instance (ie. typeof( IINode ) ) you can use: Type myType; if( myType.IsAssignableFrom( typeof( IReferenceTarget ) ) { ... } Marsel Marsel Khadiyev (Software Developer, EPHERE Inc.) |
| I was trying to write some filtering for finding nodes with objects of a specific type in the scene. But INode.ObjectRef.GetType() == typeof(some IObject) wont work. I'm assuming that the alternative is to use IsAssignableFrom? |
| Although according to the .net documentation IsAssignableFrom should not be called from within managed code. |
| Although according to the .net documentation IsAssignableFrom should not be called from within managed code. |
| How about "INode.ObjectRef is some IObject" as I wrote earlier? Marsel Khadiyev (Software Developer, EPHERE Inc.) |
| Ah right, sorry I'm blind that should do exactly what I'm looking for. Thank you :) |
| Ah right, sorry I'm blind that should do exactly what I'm looking for. Thank you :) |
| No problem, happens to me all the time :) Marsel Khadiyev (Software Developer, EPHERE Inc.) |