RAPID - Get tooldata by name [MOVED]

is there a way to get a tooldata object by its name?
var tooldata tool1 = ....
var tooldata tool2 = ....
var string name = "tool1";
var tooldata currentTool = STR_TO_TOOLDATA(name)
Any help would be appreciated,
ASC
Comments
-
Hello, you can use GetDataVal for this:
here i made quick exemple :
PERS tooldata tool1:=[TRUE,[[1,0,0],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PERS tooldata tool2:=[TRUE,[[2,0,0],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PERS tooldata currentTool:=[TRUE,[[1,0,0],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
PROC main()
STR_TO_TOOLDATA currentTool,"tool1";
waittime 3;
STR_TO_TOOLDATA currentTool,"tool2";
waittime 3;
ENDPROC
PROC STR_TO_TOOLDATA(inout tooldata tooldat,string toolname)
VAR tooldata tooltemp;
getdataval toolname,tooltemp;
tooldat:=tooltemp;
ENDPROCBR
Peter
0 -
Hi,
thanks a lot, this is exactly what i was looking for.
Regards,
ASC
0 -
Hi,
you can also use the function ArgName to get the name of the tool.
Example:
VAR string stToolName;
TASK PERS tooldata tGripper:=--
TPwrite "Tool name: "+ArgName(tGripper);
In case of you want to get or set the current tool, work object or loaddata you can also use the instructions GetSysData or SetSysData.
Best regards
Micky
0
Categories
- All Categories
- 5.6K RobotStudio
- 399 UpFeed
- 20 Tutorials
- 14 RobotApps
- 301 PowerPacs
- 406 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 336 IRC5
- 67 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 830 RAPID Programming
- 13 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 107 Collaborative Robots
- 5 Job listings