Hi,
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
Hi,
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
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;
ENDPROC
BR
Peter
Hi,
thanks a lot, this is exactly what i was looking for.
Regards,
ASC
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