Creating addon interface similar to unity

44 Views Asked by At

I am scripting in Eplan and I want to be able to create somewhat of a addon interface for it. I create a button from Setup and it has to have the [DeclareRegister] attribute for eplan to load the script. Assigning "Actions" to blocks of code to run.

public class Setup
{  
    [DeclareRegister]
    public void RegisterRibbonItems()
    {   
        //Creating a button in ribbon    
        var newTab = new Eplan.EplApi.Gui.RibbonBar().AddTab(tabName);
        var commandGroup = newTab.AddCommandGroup(groupName);                          
        var button1 = commandGroup.AddCommand("ButtonDisplayName", "ButtonAction", 1);
    }

    [DeclareAction("ButtonAction")]
    public void ButtonActionMethod()
    {
        ActionCallingContext action = new ActionCallingContext();
        action.AddParameter("ScriptFile",@"C:...\Scripts\OtherScript.cs");
        new CommandLineInterpreter().Execute("ExecuteScript",action);
        return;
    }
}

The button works and is fine. I however want to be able to expand it in a way similar to unity. Lets say I create a folder next to my Setup script, I want to be able to have all the scripts in there be able to communicate with eachother by referencing their namespaces.

E.G. I have a Library.cs script in Scripts folder

namespace Library
{
    public class SomeClass
    {
        //Methods kept in here that I use repeatedly
        public static string GetUserName()
        {
            //Code that gets username each time it is called
            string username = "";
            return userName;
        }
    }
}

And then next to Library.cs I have a script called OtherScript.cs which the button points to when clicked.

using Library;

class MyClass
{
    string user = SomeClass.GetUserName();
}
0

There are 0 best solutions below