Nirtec Studio Forum

General Category => Machines Simulator => Topic started by: Luke_128 on January 24, 2011, 04:50:52 PM

Title: Error with C# code
Post by: Luke_128 on January 24, 2011, 04:50:52 PM
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?

Title: Re: Error with C# code
Post by: EasyPLC_Master on January 24, 2011, 05:02:05 PM
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!.