Notifications
Clear all

[Closed] .NET: get/set appdata?

I’m working with IINodes in .NET and was wondering what the equivalent to maxscript’s “$.getappdata…” and “$.setappdata…” are. I see AddAppDataChunk and GetAppDataChunk methods but I’m not sure the proper way to use them. Why do they require class/superclass IDs as arguments, and how do I go about converting a .NET string to/from a byte[]?

1 Reply

Nevermind…it was as simple as


 public static void setNodeAppData (IINode node, String str, uint channel)
 {
 	  node.RemoveAppDataChunk(node.ClassID, node.SuperClassID, channel);
 	  node.AddAppDataChunk(node.ClassID, node.SuperClassID, channel, Encoding.ASCII.GetBytes(str));
 }
 			
 public static String getNodeAppData (IINode node, uint channel)
 {				
 	   IAppDataChunk chunk = node.GetAppDataChunk(node.ClassID, node.SuperClassID, channel);
 	   if (chunk != null && chunk.Data != null)
 	   {
 			return Encoding.ASCII.GetString(chunk.Data);
 	  }
 	  return null;
 }