RobotStudio event

API: Delete RsToolData

Hi!

I want to delete a RsToolData from my Task:

[code]
 if (mechRobot.Task.DataDeclarations.Contains(myTool.Name))
                                            mechRobot.Task.DataDeclarations..Remove(myTool);
[/code]

This is the error I get:

System.ArgumentException: Object must have same parent.

in
ABB.Robotics.RobotStudio.Stations.RsDataDeclarationCollection.Remove(RsDataDeclaration dataDeclaration)

in RSAddinTest.Class1.loadScene(Object sender, ExecuteCommandEventArgs e)

Can anyone please tell me why this does not work?

Best Regards, Matthias



Comments

  • Hi
    This may give you some help how to delete RsToolData


    public void Macro_DelTool()
    {
    Station stn = Project.ActiveProject as Station;
    if (stn == null) return;
    if (stn.ActiveTask.DataDeclarations.Contains("myNewTool"))
    {
    RsDataDeclaration tool = stn.ActiveTask.DataDeclarations["myNewTool"];
    stn.ActiveTask.DataDeclarations.Remove(tool);
    }
    }
    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • And the reason is that you have RsToolData in the remove method and not a RsDataDeclaration
    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering