protected override void SolveInstance(IGH_DataAccess DA) { Machina.Robot bot = null; Machina.Types.Data.RobotProgram program = null; string folderPath = ""; if (!DA.GetData(0, ref bot)) { return; } if (!DA.GetData(1, ref program)) { return; } if (!DA.GetData(2, ref folderPath)) { return; } bool success = bot.SaveProgram(program, folderPath); DA.SetData(0, success ? $"Robot program saved to {folderPath}" : $"Something went wrong saving the program, please check the Logger"); }
protected override void SolveInstance(IGH_DataAccess DA) { Machina.Types.Data.RobotProgram program = null; if (!DA.GetData(0, ref program)) { return; } List <string> code = new List <string>(); DA.SetDataList(0, program.ToStringList()); }
protected override void SolveInstance(IGH_DataAccess DA) { Machina.Robot bot = null; List <Machina.Action> actions = new List <Machina.Action>(); bool inline = false; bool comments = false; if (!DA.GetData(0, ref bot)) { return; } if (!DA.GetDataList(1, actions)) { return; } if (!DA.GetData(2, ref inline)) { return; } if (!DA.GetData(3, ref comments)) { return; } // Sanity, avoid users compiling programs with inadvertedly null actions. foreach (var a in actions) { if (a == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Can't compile a Program with `null` Actions, please review the Action list."); return; } } // Create a new instance to avoid inheriting robot states between different compilations // https://github.com/RobotExMachina/Machina-Grasshopper/issues/3 Machina.Robot compiler = Machina.Robot.Create(bot.Name, bot.Brand); compiler.ControlMode(ControlType.Offline); foreach (Machina.Action a in actions) { compiler.Issue(a); } Machina.Types.Data.RobotProgram program = compiler.Compile(inline, comments); DA.SetData(0, program); }