[C# SDK] Get Properties through api

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
Old 03 March 2014   #1
[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.
 
Old 03 March 2014   #2
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...)
Attached Files
File Type: txt accessing_properties.cs.txt (9.4 KB, 44 views)
 
Old 04 April 2014   #3
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.
 
Old 04 April 2014   #4
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!)

Quote:
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.

Quote:
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!

Last edited by sebjf : 04 April 2014 at 01:56 PM.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:03 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.