Creating New Station
This example provides information on creating a new station if no station exists.
Use this procedure to create a new station :
Initialize the API.
RobotStudioAPI.Initialize();
Check if station exists.
Create new station object.
Set active task to default task.
Set active project to station.
Note
Depending on the needs of the application/unit test certain subsystems ('services') must be initialized.
ApiServices.Geometry = new RobotStudio.Services.Geometry.GeometryService();
ApiServices.Graphics = new RobotStudio.Services.Graphics.GfxService(CreateDX);
ApiServices.Simulator = new RobotStudio.Services.Simulation.SimulatorService();
ApiServices.Controller = new RobotStudio.Services.Controller.ControllerService();
ApiServices.Modeling = new RobotStudio.Services.Modeling.ModelingService();
ApiServices.Conveyor = new RobotStudio.Services.Conveyors.ConveyorService();
ApiServices.RapidSync = new RobotStudio.Services.RapidSync.RapidSyncService();
Solution
Check if station exists.
// Set the active project as our station. Station station = Station.ActiveStation;
Create new station object.
// ...create a new one. station = new Station();
Set active task to default task.
station.ActiveTask = station.DefaultTask;
Set active project to station.
Project.ActiveProject = station;
Example
This example provides information on creating a new station object.
private Station NewStation()
{
// 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;
}
// Return a station for us to use.
return station;
}
Required Namespaces
ABB.
ABB.