[Closed] Rootnode custom attributes from .NET
Greetings
I’m working on moving some of my Maxscript functions into C#, uaing Autdesk.Max.DLL where I plan to run some heavy calculations, which will return new object positions. The objects i wish to affect are already referenced in various rootnode.custattribs in my scene, but I’m not sure how to interrogate the scenes custom attributes using the wrapper.
I’m just playing in the listener for now…
AssemblyType = dotNetClass "System.Reflection.Assembly"
maxroot = pathConfig.GetDir #maxroot
AssemblyType.LoadFile (maxroot + "\Autodesk.Max.dll")
GlobalInterfaceType = dotNetClass "Autodesk.Max.GlobalInterface"
global GI = GlobalInterfaceType.Instance
global i14= GI.COREInterface14
catt = i14.rootnode.CustAttribContainer__Animatable
catt.NumCustAttribs
(returns 1, which is correct)
now how the heck do I look inside it? Get a node reference from inside? Or work with multiple sets of custom attributes (of different types) Sifting through the methods, and properties is doing my head in…
Once I get the syntax straight in my head I’ll move to visual studio…
Thanks for the assistance.
Mikie
Thanks Dennis!
I was looking for the ‘get’ accessor in the huge list of properties, but somehow missed it!!!
Wow, this is opening up a massive can of worms (and possibilities) ! Where is the best place to look for practical examples of working with parameter block data, etc? My expectations for intuitiveness are sadly incorrect. And this is just trying to work with a boolean, let alone the nodes I’ll want to transform…
So I get my custom attribute, then i get it’s parameterblock defenition?, then I get a property in the parameter block… somewhow… and somehow read and write it’s value… the procedure for which I’m sure depends on the value type? And I’m getting more and more lost in the zillion GetValue? overloads i.E.
.<System.Boolean>GetValue <System.Int16>id <System.Int32>t <System.Int32&>v <Autodesk.Max.IInterval>ivalid <System.Int32>tabIndex
att = (catt.GetCustAttrib 1)
pb = att.getParamBlock 0
val = pb.getparamdef 7
val.IntName
<returns “autoUpdateFromDatabase” > yay!
but how do I get and set true/false.
The “Autodesk.Max.dll” is already loaded so in order to get the Interface14 you only need to type
global GI = (dotNetClass "Autodesk.Max.GlobalInterface").instance
global i14= GI.COREInterface14
here is your “mxs” + “autodesk.max” stops …
to get a param block value you have to pass pointer to System.Int32 variable.
this is your method
.<System.Boolean>GetValue <System.Int16>id <System.Int32>t <System.Int32&>v <Autodesk.Max.IInterval>ivalid <System.Int32>tabIndex
but there is no easy way to pass pointer to a .net object by mxs
aaah OK… I’ll guess I’ve have to move out of the listener, and into visual studio.
I was kind of hoping to have more of an idea what I was doing first
The big picture is that I’m trying to flag potential object collisions, based on known stopping rates/trajectories, and subsequently move other objects out of the way.
A colleague has the c# code which checks for this collision condition, but It would be too slow to try to run it from MxS.
The previous way I would have done this is to pass arrays of floats into methods defined in a helper .dll we have written in C#.
However, collecting all the data to pass out, via maxscript is turning out to be the bottleneck, so I’m trying to figure out how to just switch the feature on via my existing maxscript tools, and have everything else happen in C#… i.e. listen for timechange events, and transform change on a list of objects, change wire color if collision conditions are met, and move other objects out of the way…