Hello,
right now I am trying to program an ADD-IN for Robot Studio. As described under the link : “http://developercenter.robotstudio.com/robotstudio/api_reference?url=html%2F4ffca351-267a-4b49-a512-81638c3b21bf.htm”, I use Visual Studio an have the Robot Studio SDK installed.
If i use the first example “Creating a Robot Studio add-in” (http://developercenter.robotstudio.com/robotstudio/api_reference?url=html%2F4ffca351-267a-4b49-a512-81638c3b21bf.htm) it works out pretty well. After putting the .dll and .rsaddin files in the appropriatet folder, I can display a text file in Robot Studio. So Robot Studio basically recognizes my programed ADD-IN an is able to execute it. :blush:
My next attempt is to create a simple robot via an ADD-IN. So I oriented myself to the example “Creating a Robot with Custom parts”.
(http://developercenter.robotstudio.com/robotstudio/api_reference?url=html%2F4ffca351-267a-4b49-a512-81638c3b21bf.htm)
I used parts of the given example source code. When i try to activate the Add in i get a “NullReferenceException” Error-Message from Robot Studio:
When I proceed the source code step by step - at the line 37 - of creating a “new Part()” for the basePart, the new part becomes null/zero and that is the Point where the source jumps into the “catch” and an Error appears.
The description of the Class “Part” says: “A Part is a container for bodies, and can hold zero or more bodies. A part also contains an orientation.”
I am confused because the error comes before I can assign something to the “new Part()” and the descriptions also says zero is okay,.. :neutral:
I Hope somebody has an idea or can Help me,.. I would be incredibly thankful !!! ![]()
.rsaddin
**
**
Complete source:
using System;
using System.Collections.Generic;
using System.Text;
//Hinzugefügt - Verweise - add - .NEt und System.AddIn
using System.IO;
using ABB.Robotics;
using ABB.Robotics.RobotStudio.Controllers;
using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;
using ABB.Robotics.RobotStudio.Stations.Forms;
// Die XXXXXX.rsaddin muss in den Addin File von Robot Studio kopiert werden
// C:\Program Files (x86)\Common Files\ABB Industrial IT\Robotics IT\RobotStudio\AddIns
namespace RobotStudioEmptyAddin1
{
public class Class1
{
public static void AddinMain()
{
Logger.AddMessage(new LogMessage(“Dies ist ein Test-Addin für RobotStudio”));
BaueEinenRobbi();
}
private static void BaueEinenRobbi()
{
Project.UndoContext.BeginUndoStep(“Create A Robot”);
try
{
Station station_1 = Project.ActiveProject as Station;
Part basePart = new Part();
Body baseBody = Body.CreateSolidBox(new Matrix4(new Vector3(0, 0, 0)), new Vector3(0.3, 0.3, 0.3));
basePart.Bodies.Add(baseBody);
Part linkPart_1 = new Part();
Body linkBody_1 = Body.CreateSolidCylinder(new Matrix4(new Vector3(0, 0, 0)), 0.05, 0.5);
//Shape an die richtige Stelle verschieben:
linkBody_1.Transform.RX = Globals.DegToRad(-90);
linkBody_1.Transform.Translation = new Vector3(0.15, 0, 0.35);
linkPart_1.Bodies.Add(linkBody_1);
Part linkPart_2 = new Part();
Body linkBody_2_torus = Body.CreateSolidTorus(new Matrix4(new Vector3(0, 0, 0)), 0.1, 0.05);
//Shape an die richtige Stelle verschieben:
linkBody_2_torus.Transform.RY = Globals.DegToRad(90);
linkBody_2_torus.Transform.RZ = Globals.DegToRad(90);
linkBody_2_torus.Transform.Translation = new Vector3(0.15, 0.5, 0.35);
Body linkBody_2_cone = Body.CreateSolidCone(new Matrix4(new Vector3(0.15, 0.5, 0.45)), 0.03, 0.1);
linkPart_2.Bodies.Add(linkBody_2_torus);
linkPart_2.Bodies.Add(linkBody_2_cone);
MechanismBuilder mb = new MechanismBuilder(MechanismType.Robot);
mb.ModelName = “Mein Robbi”;
mb.Name = “Mein Roboter”;
mb.AddLink(“Base”, basePart);
mb.AddLink(“Link1”, linkPart_1);
mb.AddLink(“Link2”, linkPart_2);
mb.BaseLink = “Base”;
//Gelenke einfügen
mb.AddJoint(“Joint”, “Base”, “Link1”, new Vector3(0, 0, 0), new Vector3(0, 1, 0), JointType.Prismatic, true);
mb.AddJoint(“Joint2”, “Link1”, “Link2”, new Vector3(0.15, 0.5, 0.35), new Vector3(0.15, 0.6, 0.35), JointType.Rotational, true);
mb.SetJointLimit(“Joint1”, -0.13, 0.2);
mb.SetJointLimit(“Joint2”, -Math.PI, Math.PI);
mb.BaseFrame = Matrix4.Identity;
double homeJointPos = { 0, 0 };
mb.SetSyncJointPosition(homeJointPos);
Matrix4 calPos = { Matrix4.Identity };
mb.SetCalibrationPosition(calPos);
int jointMask = { 1, 1, 0, 0, 0, 0 };
mb.SetJointMask(jointMask);
Mechanism mech = mb.CompileMechanism();
station_1.GraphicComponents.Add(mech);
GraphicComponentLibrary gcl = mech.MoveDefinitionToLibrary();
string userProjPath = (string)Options.GetValue(“RobotStudio”, “Directories.UserProjects”);
if (userProjPath != null)
{
gcl.SaveAs(userProjPath + “\Libaries\myRobot_TEST.rslib”);
}
else
{
// gcl.SaveAs(userProjPath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), “myRobot_TEST.rslib”));
}
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
}






