News:

SMF - Just Installed!

Main Menu

Error with C# code

Started by Luke_128, January 24, 2011, 04:50:52 PM

Previous topic - Next topic

Luke_128

I'm having a trouble with my installation code.

I want to move a staticmodel component when a PLC output is active and this is my code:


   if(IO.GetOutput(3))
   {
      if(vct.X < 5.1f)
      {
          vct.X += 0.12f;
          Editor.Translate(1, vct);
      }
   }


But when I run the installation and I active the output number 3 I get an error:

ERROR In Logic Program
Object reference not set to an instance of an object


Can you help me?


EasyPLC_Master

The code is OK!
The problem that do you have is that the collisionable property of the Static Model object is set to false, then the body object is not set and the component can't be moved.
Try to change the collisionable property to true, sure then it works!.