
How to create a tool using the API (C#)?

in RobotStudio
Hi everyone,
it's me again. I have another problem: i want to create a tool through the API.
With the "Create Tool" Wizard in RS it is no problem, but how can i create a tool (tooldata + graphic representation, e.g. a cylinder) with C#?
Regards, Matthias
it's me again. I have another problem: i want to create a tool through the API.
With the "Create Tool" Wizard in RS it is no problem, but how can i create a tool (tooldata + graphic representation, e.g. a cylinder) with C#?
Regards, Matthias
0
Comments
-
Hi,
firstly a solution for your tooldata problem (without any geometry attached):
RsTask task = station.ActiveTask;
RsToolData tool = new RsToolData();
tool.Name = "NewTool";
tool.Frame.Z = 0.250; // or whatever
task.DataDeclarations.Add(tool);
task.ActiveTool = tool;
This should give you a new tooldata declaration and set it to the active one.
apox2010-03-05 01:45:110 -
and here a sample with geometry (mechanism of type tool):
Station station = Project.ActiveProject as Station;
RsTask task = station.ActiveTask;
// create sample geometry
Part part = new Part();
part.Bodies.Add(Body.CreateSolidCylinder(Matrix4.Identity, 0.030, 0.250));
part.Name = "MyToolPart";
// create new tool
MechanismBuilder b = new MechanismBuilder(MechanismType.Tool);
b.Name = "MyToolName";
b.ModelName = "MyToolModelName";
string link = "Geometry";
b.AddLink(link, part);
b.BaseLink = link;
Matrix4 offset = Matrix4.Identity;
offset.TranslateLocal(0.0, 0.0, 0.250);
// ...
// assign gravity, offset, ...
b.AddToolData("MyToolData", link, offset, new Vector3(0,0,1), new Vector3(0,0,1));
Mechanism mechTool = b.CompileMechanism();
mechTool.Name = "MyMechanism";
station.GraphicComponents.Add(mechTool);
// and attach it to the flange:
// of course you should check if flange does exist and so on
task.Mechanism.GetFlanges()[0].Attach(mechTool, true);
Hope that helps.
apox2010-03-05 01:48:120 -
Thank you, that was exactly what i needed. I'll try it as soon as i am back in office!
Matthias
0
Categories
- All Categories
- 5.5K RobotStudio
- 398 UpFeed
- 19 Tutorials
- 13 RobotApps
- 299 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 324 IRC5
- 63 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 813 RAPID Programming
- 6 AppStudio
- 3 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings