AddStaement with .Net C# API

Hi,

I’d like to manipualte a Robot in C# langage with the .Net API.

I’ve translated an Python example until the AddStatement methode.

Now I can’t find Statement in C# like (VC_STATEMENT_PTPMOTION VC_STATEMENT_DELAY) in Python.

Can anyone Help?

 

 

	public class Class1 : IPlugin
    {

		private Lazy<IApplication> app = null;
		private IProgram robotProgram;

		void Exit()
		{
		}
		void Initialize()
		{
			IMessageService ms = IoC.Get<IMessageService>(); //IMessageService est une interface
			ms.AppendMessage("Hello World", MessageLevel.Warning);

			ISimWorld simWorld = app.Value.World;
			ISimComponent comp = simWorld.CreateComponent("Example2");

			IRobotExecutor robotExe = (IRobotExecutor) comp.FindBehavior("rRobotExecutor");// Création du robot
			// pilotage du robot
			robotProgram = robotExe.Program;
			var mainRoutine = robotProgram.MainRoutine;
			// Add Staement
	        	var statement = mainRoutine.AddStatement( ??? );
...
                }
    }

 

Hi SebLinck,

See the first example of post:

https://forum.visualcomponents.com/forums/topic/path-creation-using-net/#post-7967

If you specifically want to use AddStatement method with the signature in your example do it like:

var statement = routine.AddStatement(typeof(IJointMotionStatement), false);

 

P.S In your example, you create an empty component. So, instead of finding robot executor you have to create one (createBehavior -method) or (preferred) find a robot in the layout that has the executor already and work with that. See a simple example of finding first component in the world having a RobotController behavior.

protected ISimComponent FindFirstRobot(IApplication app)
{
    foreach (var comp in app.World.Components)
    {
        if (comp.Behaviors.FirstOrDefault(beh => beh.Type == BehaviorType.RobotController) != null)
            return comp;
    }

    return null;
}

Good luck!

I have this question too, Had you solved it?