Re: [script] How do you return anything from a c# command to jscript?

Date : Thu, 8 May 2008 12:39:43 -0700
To : XSI(at)Softimage.COM
From : "Graham D Clark" <mailgrahamdclark(at)gmail.com>
Subject : Re: [script] How do you return anything from a c# command to jscript?
its ok, disregard.
--
Graham D Clark, VFX/CG Supervisor, ph:fad-take-two
http://www.linkedin.com/in/grahamclark | http://www.xsibase.com/articles.php?detail=117

On Thu, May 8, 2008 at 11:58 AM, Graham D Clark <mailgrahamdclark(at)gmail.com> wrote:
Is there something I need to do to get the value in js?
Like in eg below shouldn't I at least get back "true" or 1? Its just code generated straight from the SDK wizard, and then I call it with one js line
logmessage(testreturn());
and I get "// INFO :"
I get nothing.
I've tried returning objects,strings, arrays, etc. and various suggestions found online to return values from c# to jscript.
I'm missing something basic I guess, any help greatly appreciated.

// testreturnPlugin
// Initial code generated by XSI SDK Wizard
// Executed Thu May 8 11:44:56 PDT 2008 by gdc
//
// Tip: You need to compile the generated code before you can load the plug-in.
// After you compile the plug-in, you can load it by clicking Update All in the Plugin Manager.

using System;
using Softimage.XSIOM; // XSI object model
using Softimage.XSIMath;
using Softimage.XSIUtil;

//
// This sample class is used to demonstrate how a base class can be used to implement plug-in items.
//

public class Base
{
    CXSIApplicationClass m_xsi;
    CXSIFactoryClass m_fact;
    CXSIUtilsClass m_utils;

    protected Base()
    {
        m_xsi = new CXSIApplicationClass();
        m_fact = new CXSIFactoryClass();
        m_utils = new CXSIUtilsClass();
    }
    protected bool Log(String str)
    {
        m_xsi.LogMessage(str, siSeverity.siVerbose);
        return true;
    }

    protected bool Info(String str)
    {
        m_xsi.LogMessage(str, siSeverity.siInfo);
        return true;
    }

    protected bool Error(String str)
    {
        m_xsi.LogMessage(str, siSeverity.siError);
        return true;
    }

    protected XSIApplication GetXSI()
    {
        return m_xsi;
    }

    protected XSIFactory GetFactory()
    {
        return m_fact;
    }

    protected XSIUtils GetUtils()
    {
        return m_utils;
    }   
}


public class XSIPlugin : Base
{
    public bool Load( PluginRegistrar in_reg )
    {
        in_reg.Author = "gdc";
        in_reg.Name = "testreturnPlugin";
        in_reg.Email = "";
        in_reg.URL = "">        in_reg.Major = 1;
        in_reg.Minor = 0;

        in_reg.RegisterCommand("testreturn","testreturn");
        in_reg.RegisterMenu(siMenuAnchorPoints.siMenuTbGetPrimitiveID,"testreturn_Menu",false,false);
    //RegistrationInsertionPoint - do not remove this line

        return true;
    }

    public bool Unload( PluginRegistrar in_reg )
    {
        String strPluginName = null;
        strPluginName = in_reg.Name;
        Log(strPluginName + " has been unloaded.");
        return true;
    }

}

public class testreturn : Base
{
    public bool Init( Context in_ctxt )
    {
        Command oCmd = null;
        oCmd = (Command)in_ctxt.Source;
        oCmd.Description = "";
        oCmd.ReturnValue = true;

        return true;
    }

    public bool Execute( Context in_ctxt )
    {

        Log("Execute called");
        CXSIApplicationClass app = new CXSIApplicationClass();
        app.LogMessage(app.Name + " adsadsadasdadsa ", siSeverity.siInfo);
        return true;
    }

}

public class testreturn_Menu : Base
{
    public bool Init( Context in_ctxt )
    {
        Menu oMenu = null;
        oMenu = (Menu)in_ctxt.Source;
        oMenu.AddCommandItem("testreturn","testreturn");
        return true;

    }

}




On Thu, May 8, 2008 at 7:42 AM, Marc-André Belzile <mbelzile(at)softimage.com> wrote:
Same as scripting, enable the Context.ReturnValue prop in the Init method and return the calue from the Execute method with the return statement.
 
-mab


From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Graham D Clark
Sent: May-08-08 5:38 AM
To: xsi(at)Softimage.COM
Subject: [script] How do you return anything from a c# command to jscript?

I'm new to c#.
How do you return anything from a c# command to jscript?
Thanks, Graham
--
Graham D Clark, VFX/CG Supervisor, ph:fad-take-two
http://www.linkedin.com/in/grahamclark | http://www.xsibase.com/articles.php?detail=117



--
Graham D Clark, VFX/CG Supervisor, ph:fad-take-two
http://www.linkedin.com/in/grahamclark | http://www.xsibase.com/articles.php?detail=117





Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.