HOW TO FAST CREATE ARRAY OF TARGETS? RS 5.13 API
stn.ActiveTask.DataDeclarations.Add(robTarget);
RsTarget target = new RsTarget(wobj, robTarget);
Comments
-
Hi LukcyHunter welcome to the forum,
When you create targets like that in RobotStudio they become a graphical object which is displayed in the graphics window. That is what is slowing you down.
I'd suggest a rethink here, why would you add all targets to the RobotStudio station at once? When instead you can use the PC SDK to create them in the controller directly, divide them up, maybe 1k targets in each module, then if you need them in RobotStudio you can sync a module at a time to the station and when you are done with that module sync it back and remove it from the station before starting on the next one. That way you don't have tens of thousands of graphical objects in the station at once.By the way, your code sample contains errors so for the lurkers here is a working macro instead.
public void Macro_GimmeTargets()
{
Logger.AddMessage(new LogMessage("Start targets"));
Station stn = Project.ActiveProject as Station;
if (stn == null) return;
for (int x = 0; x < 100; x++)
{
RsRobTarget robTarget = new RsRobTarget();
robTarget.Name = stn.ActiveTask.GetValidRapidName("MyRobTarget", "_", 10);
stn.ActiveTask.DataDeclarations.Add(robTarget);
RsTarget target = new RsTarget(stn.ActiveTask.ActiveWorkObject, robTarget);
stn.ActiveTask.Targets.Add(target);}
Logger.AddMessage(new LogMessage("Stop targets"));
}John
Developer Center0 -
Hi LuckyHunter,I think the call GetValidRapidName() can be quite time consuming also.But anyway, for such a large amount of targets I agree with John.
Niklas Skoglund2011-06-28 13:53:090 -
Thanks for answers.Will try it..By the way, are there any example how to create targets controller directly with PC SDK ?Regards, Roman0
-
[Quote]PC SDK Application Manual
Using the PC SDKMotion domain[/quote]Note that using the PC SDK you could insert RAPID directly from string which would be even faster, however you would then not get the check for duplicate names and syntax.John Wiberg2011-06-29 14:38:01John
Developer Center0 -
I remember back then :-) John and skogisI had kind of the same problem doing plasma spraying for PraxAir in US but on RS4 but it took like a day(at least it felt like that) to create all the targets and the total was just only like 4000-5000. And basically a plasma path(a lot of them, but usally you just work on one path at a time ) was only around 100 targets.So I created an addin(and RS5 is much more powerfull now than back then) where you where able to create/sync/delete each path, and a lot of other functions, so that you only had the targets you wanted to work with in RS.I know this won't solve your problem but maybe it will give you a hint to approach the problem in another direction.Per Svensson
Robotics and Vision Specialist
Consat Engineering0 -
Thanks---------------------------------------------------------0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings