RobotStudio event

Create new Station RobotStudio SDK

Options
Hi,
I want to create with visual Studio a new Station in RobotStudo. So the problem is, it function to create a new one, but if it opens the new Station there is no graphic window where I can see my Graphic Components like a Box or something else and I don't know how to put a new view in my Station. 
Can someone Help me? I am at beginning to learn RobotStudio SDK


My Code is this 
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;
using RobotStudio.API.Internal;
using ABB.Robotics.RobotStudio.Stations.Forms;
using System.IO;
using System.Drawing;
using System.Threading;
namespace LokalenUrsprungVeraendern
{

    public class Class1
    {

        private static void AddinMain()
        {
           
          
            Project.UndoContext.BeginUndoStep("CameraProperties");
            try
            {
                // Set the active project as our station.
                Station station = Station.ActiveStation;
                // If there is no active project...
                if (station == null)
                {
                    // ...create a new one.
                    station = new Station();
                    station.ActiveTask = station.DefaultTask;
                    Project.ActiveProject = station;
                 
                }

                // Create a Camera.
                Camera myCam = new Camera();
                // Set the camera to look at a specific point.
                myCam.LookAt = new Vector3(0, 0, 0);
                // Set the camera to view from a specific point.
                myCam.LookFrom = new Vector3(10, 10, 10);
                // Fix the camera to this point.
                myCam.LockRotate = 0.0;
                myCam.LockTranslate = 0.0;
                myCam.LockZoom = 0.0;
                // Add it to the stations camera collection.
                station.Cameras.Add(myCam);
                // Sync the current view to the camera view.
                GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
                // Use the camera as the true camera.
                // This make sure that the constraints on the movement kicks in.
                GraphicControl.ActiveGraphicControl.Camera = myCam;
            }
            catch
            {
                Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
                throw;
            }
            finally
            {
                Project.UndoContext.EndUndoStep();
            }
        }
    }
}


Comments

  • scottdf93
    Options
                        station = new Station();
                        station.ActiveTask = station.DefaultTask;
                        Project.ActiveProject = station;

                        // Creates new viewer in the station
                        GraphicControl gc = new GraphicControl();
                        gc.RootObject = station;
                        Camera cam = new Camera();
                        cam.LookFrom = new Vector3(10, 10, 10);
                        gc.Camera = cam;
                        gc.ShowFloor = true;
                        gc.ShowUCSGrid = true;
  • Aliwe
    Options
    while compilation this command: Station station = Station.ActiveStation;  makes this error  this error : System.TypeInitializationException
      HResult=0x80131534
      Message=The type initializer for 'ABB.Robotics.RobotStudio.Stations.Station' threw an exception.

    Inner Exception 1:
    ReflectionTypeLoadException: Unable to load one or more of the requested types.
    Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
    Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
    This means that the connection with RobotStudio through SDK was not established. What is the solution for that?
    I appreciate any help!