Hi,
I am trying to create a tool from a geometry.
There is an Xml-file with the data I need for the tool.
It stores the path to the Cad-file, its center of gravity, its position in the wrist coordinate system and so on.
I can import the geometry from a given CAD-model via
GraphicComponentLibrary gcl = GraphicComponentLibrary.Load(reader.GetAttribute("path"), false);
station.GraphicComponents.Add(gcl.RootComponent.CopyInstance ());
I can also create a tool with data from an Xml-reader via
RsToolData tool = new RsToolData();
tool.ModuleName = "Module1";
tool.Name = reader.GetAttribute("name");
tool.RobotHold = true;
tool.Frame.X = Convert.ToDouble(reader.GetAttribute("x"));
tool.Frame.Y = Convert.ToDouble(reader.GetAttribute("y"));
tool.Frame.Z = Convert.ToDouble(reader.GetAttribute("z"));
tool.Frame.RX = Globals.DegToRad(Convert.ToDouble(reader.GetAttribute("rx")) );
tool.Frame.RY = Globals.DegToRad(Convert.ToDouble(reader.GetAttribute("ry")) );
tool.Frame.RZ = Globals.DegToRad(Convert.ToDouble(reader.GetAttribute("rz")) );
//Create the loaddata for the tool
RsLoadData myloadData = new RsLoadData();
//Set mass
myloadData.Mass = Convert.ToDouble(reader.GetAttribute("mass"));
//Set center of gravity
myloadData.Cog = new Vector3(Convert.ToDouble(reader.GetAttribute("cogx")), Convert.ToDouble(reader.GetAttribute("cogy")), Convert.ToDouble(reader.GetAttribute("z")));
//Set the Axis of moment
myloadData.Aom = new Quaternion(Convert.ToDouble(reader.GetAttribute("aomx")), Convert.ToDouble(reader.GetAttribute("aomy")), Convert.ToDouble(reader.GetAttribute("aomz")), Convert.ToDouble(reader.GetAttribute("aomw")));
//The load can be considered a point mass, in this example, i.e. without any moment of inertia
myloadData.Inertia = new Vector3(0, 0, 0);
tool.LoadData = myloadData;
//Show the name of the tooldata in the graphics
tool.ShowName = true;
//Show the tool data in the graphics
tool.Visible = true;
//Add the tool data to the active task
station.ActiveTask.DataDeclarations.Add(tool);
There are some problems I could not solve:
- How can I attach the geometry to a robot? In Rs it is just drag&drop, but with the API…?!
- How can I connect the RsToolData with the geometry?
Should I load the geometry as a Part?
Part has a method called attach, but I have no clue how to use it
Is this possible with the API?
Best regards and a happy new year,
Matthias