Notifications
Clear all

[Closed] [C# SDK] Get Properties through api

Anyone know how to get a “node’s” properties via c++ or c# (i realize node is a misnomer here… animatable/or a subclass i guess is more accurate).

Essentially something similar to the mxs command ‘getPropNames’, or even doing a <SubAnim>.value in maxscript.

I’ve tried recursing the sub animation tree of a node and its object ref and, while i can get the value of an IAnimatable that has an IControl interface, i cannot get the value just from an IAnimatable.

I have also tried getting the parameter block from each IAnimatable/INode/ObjctRef, in the recurse loop, however i have not been able to retrieve the parameter block… its always null.

I’m not even sure if properties are stored on a ParameterBlock, or via some other interface. I have been unable to find good reference to this in the docs or examples.

Just thought someone else may have tried this before. Thanks in advance.

3 Replies

Hi andylt1, I also think the documentation for this is very lacking. Therefore, I am not sure if this is the right way, but attached is code I use to create material objects and set their properties (contained in IIParamBlock2) using C#.

(Note the Parameter class in that file is not very well implemented, but you get the idea from the first half…)

Apologies for the late response… just got a chance to jump back on this.

Many thanks for the code Sebastian.

I see you are passing an IReferenceMaker to gather the Parameter block data. I have been trying to use IAnimatable for this. Im guessing that was something that was halting me previously.
I still am a bit unsure of the differences between IReferenceMaker and IAnimatable, and why you would use one over the other.

I also noticed you did ‘if (iref is IIParamBlock2)’, which i never thought of doing.
I guess, as IIParamBlock2 is a subclass of a IReferenceMaker (?? i think), it can be re-cast and used in equality tests; or its been overloaded for == operator. (My amateur c# showing its face there :)).

Anyway, I’m sure my answer lies in your example… I’ll try implementing something soon.

Thanks again.

Hi andylt1, you are welcome, I hope it helps! (I do not work for Autodesk though, so don’t think my way is any more correct than any other you come up with!)

I still am a bit unsure of the differences between IReferenceMaker and IAnimatable, and why you would use one over the other.

The ParamBlocks (which contain the properties) are objects which are referenced by ‘IAnimatibles’; I use IReferenceMaker because it defines the method GetReference(int) used to get those objects.

I guess, as IIParamBlock2 is a subclass of a IReferenceMaker (?? i think), it can be re-cast and used in equality tests

Careful there :), I use GetReference() to get an object from IReferenceMaker, this object is an IReferenceTarget and is the one that you cast to a ParamBlock or the like. I never cast the IReferenceMaker (the node) to anything.

Essentially what this does is get a list of all the ‘members’ of the node/animatible, and checks their type, looking for ParamBlock2 and working through its contents when found.

I also note that IAnimatible has a NumParamBlocks property and GetParamBlock() method. This may be better, if only because you don’t have to do so much checking and casting. Though I am sure I tried this before but can’t remember why I didn’t use it… I might try it again later.

Best of luck!