[Closed] Send data from C# to Maxscript (Property/variable data)
(
local source = "using System;
namespace mxs
{
public class myclass
{
private string _testString;
public string GetTestString { get { return _testString; } set { _testString = value; } }
}
}"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add("System.dll");
compilerParams.ReferencedAssemblies.Add("System.IO.dll");
compilerParams.GenerateInMemory = on
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #( source as string )
if (compilerResults.Errors.Count > 0 ) then
(
local errs = stringstream ""
for i = 0 to (compilerResults.Errors.Count-1) do
(
local err = compilerResults.Errors.Item[i]
format "Error:% Line:% Column:% %\n" err.ErrorNumber err.Line err.Column err.ErrorText to:errs
)
format "%\n" errs
undefined
)
else
(
compilerResults.CompiledAssembly.CreateInstance "mxs"
)
)
(
x = dotNetObject "mxs.myclass"
format "should return undefined >> %\n" x.GetTestString
x.GetTestString = "test"
format "should return test >> %\n" x.GetTestString
)
Thanks Sergey!! I’m getting mad with this.
David, the only thing you can do is show both of your codes, C# and MaxScript, and we may find your problem. But the problem isn’t where you think it is.
Yes, this is what I imagined… Computers can do many things but not magic (at least to date).
On the ‘on TestOut2Max open do’ event you create an object instance of your class, a new one. Why the hell should it be the one you are feeding with your sensor app?
You must get the instance you are updating from the sensor app or, directly, feed the one you create with Max with your app.
P.S. 1: By the way, the loading assembly should be at the start of your script or create a global for it and check in the ‘open’ event if it is already loaded. You can load a dll only once.
P.S. 2: Programming is entertaining and fun, but it’s a professional job too. I do not know why there is a general idea of what anyone can do it with a few clever copy/paste.
What do you think you are doing when you write:
classObj = dotNetObject "MyNameSpace.Out2Max"
Recent Topics
-
Need help with script to automate certain things
By siddhartha 1 week ago
-
By Dave 3 months ago
-
By MZ1 1 year ago
-
By brianstorm 1 year ago
-
By MZ1 1 year ago
-
Support class with multiple name (C#,SDK)
By MZ1 1 year ago
-
How to sort subarrays for Mat ID swapping
By brianstorm 1 year ago